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

Question

Simulate a deterministic single-threaded timer event loop. You are given tasks as [scheduled_time, duration, id]. The loop processes tasks in order of scheduled_time; ties are broken by lower id. The CPU runs one task at a time to completion (no preemption). A task cannot start before its scheduled_time; if the CPU is busy past that time, it starts when the CPU frees, and if the CPU is idle before scheduled_time, the loop waits. Return a list of [id, start_time, end_time] in execution order.

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