Code RoomRound-robin scheduler simulation
HardPrep Room Coding #1242

Round-robin scheduler simulation

CodingConcurrencySenior–Staff~40 min

Simulate a deterministic single-threaded round-robin CPU scheduler with quantum Q. You are given tasks as [arrival_time, burst_time], indexed 0..n-1. At each scheduling moment the ready queue is processed FIFO; the running task executes for min(Q, remaining) time units, then if still unfinished re-enters the back of the queue. A task arriving at exactly the moment another is re-queued is enqueued BEFORE the re-queued task. If the CPU is idle and no task is ready, time jumps to the next arrival. Return a list of completion times indexed by task.

Implement
round_robin(tasks: list[list[int]], quantum: int) → list[int]
Examples
in[[[0,5],[1,3]],2]out[8,7]
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.

0:00 of about 40 min
InputExpectedGot
[[[0,5],[1,3]],2][8,7]not run yetsample