Code Room
CodingMediumcod-g1124
Subject SchedulingLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

Simulate a fair round-robin scheduler. You are given a list of tasks as [name, arrival_time, total_burst] and a fixed time quantum. At each step the scheduler runs the head of the ready queue for min(quantum, remaining) time units; tasks become ready (and join the tail of the queue) at their arrival_time. When a running task is preempted with work left, it re-joins the tail AFTER any tasks that arrived during its slice. Ties on arrival are broken by the order in the input list. Return the list of (name, start_time, end_time) execution slices in chronological order. If the CPU is idle and a task has not yet arrived, time fast-forwards to the next arrival.

Implement
round_robin(tasks: list[list], quantum: int) → list[list]
Examples
in[[["A",0,5],["B",1,3]],2]out[["A",0,2],["B",2,4],["A",4,6],["B",6,7],["A",7,8]]
What a strong answer looks like

State 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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.