Task order on a single core
A processor with one core gets tasks, where tasks[i] = [arrive, length]: task i can start at time arrive or later and runs for length time units without pausing. Whenever the core is free and at least one task has arrived and is waiting, it starts the waiting task with the shortest length, breaking ties by the smaller index i. If none is waiting, the core sits idle until the next arrival. A task that arrives just as another ends counts as waiting. Return the indexes in the order the core runs them.
There is at least one task, arrive ≥ 0 and length ≥ 1; tasks is not sorted. Aim for O(n log n).
Besides the tests, one large input (3,000 tasks) with a ~220 ms limit (scaled to your device's speed): brute force won't pass.
Examples
task_order([[0,4],[1,2],[2,1],[3,3]])→[0,2,1,3]task_order([[5,2],[5,2],[5,1]])→[2,0,1]task_order([[0,1],[10,3],[4,2]])→[0,2,1]