Event loop priority task scheduler
Your task
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.
Examples
event_loop_order(events: list[list]) -> list[str]Example 1
Input
event_loop_order([["push", 2, 0, "a"], ["push", 1, 1, "b"], ["run"], ["run"]])Output
["b", "a"]