Code Room
CodingMediumcod-g1018
Subject Concurrency event loop schedulingLevel Mid–Senior~25 minCommon in Concurrency · Algorithms & data structures interviewsIndustries Software development, Technology

Question

An event loop pulls tasks from a priority queue. Each task is [priority, seq, name] where a SMALLER priority value runs first; ties are broken by smaller seq (the order the task was enqueued). The loop receives an `events` stream where each event is either ["push", priority, seq, name] (enqueue a task) or ["run"] (pop and execute the highest-priority ready task, if any). Process the events in order and return the list of task names in the order they were executed by the "run" events. A "run" with an empty queue executes nothing.

Implement
event_loop_order(events: list[list]) → list[str]
Examples
in[[["push",2,0,"a"],["push",1,1,"b"],["run"],["run"]]]out["b","a"]
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.