Smallest worst ticket overrun

Write codeMedium22 min

Your task

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.

Examples

min_worst_overrun(handle_minutes: list[int], waited_minutes: list[int], sla_minutes: list[int]) -> int
Example 1
Inputmin_worst_overrun([12, 4], [50, 0], [60, 20])
Output2
Example 2
Inputmin_worst_overrun([5, 5, 5], [0, 0, 0], [30, 40, 50])
Output-25