Smallest worst ticket overrun
A support agent picks up a queue of tickets at the start of a shift and works them one at a time, never idling and never pausing a ticket once it starts. Ticket i takes handle_minutes[i] to work, has already been open for waited_minutes[i] when the shift starts, and its contract allows a total wait of sla_minutes[i] counted from the moment it was opened. Its overrun is how many minutes past that allowance the agent finishes it, negative when the agent finishes early. You choose the order. Return the smallest overrun the worst ticket in the queue can end with. All three lists have the same length, and an empty queue returns 0.
min_worst_overrun(handle_minutes: list[int], waited_minutes: list[int], sla_minutes: list[int]) → int[[12,4],[50,0],[60,20]]out2[[5,5,5],[0,0,0],[30,40,50]]out-25State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[12,4],[50,0],[60,20]]2not run yetsample[[5,5,5],[0,0,0],[30,40,50]]-25not run yetsample