Code Room
CodingHardcod-g676
Subject Concurrency simulationLevel Senior–Staff~40 minCommon in Concurrency interviewsIndustries Software development

Question

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.

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.