6 September 2026 · Advanced track
Support Queue Rotation
Simulate a round-robin support queue and report the order in which tickets get fully resolved.
A support queue processes tickets in rotation. Each ticket is given as (name, minutes_remaining), listed in the order they start in the queue. Handle the ticket at the very front of the queue for exactly one minute, which reduces its remaining time by one. If the ticket still has time remaining after that minute, send it to the back of the queue, behind every ticket currently waiting. If the ticket reaches zero remaining minutes, it is finished. Record its name and remove it from the queue, then continue with the next ticket at the front. Keep repeating this until every ticket has finished. Return a list of ticket names in the order they finished.
Constraints
tasks is a non-empty list of (name, minutes_remaining) tuples, listed in the queue's starting orderEvery name is uniqueminutes_remaining is a positive integer for every ticket
Function signature
def rotation_finish_order(tasks):