sortedTasks
that includes each task with its original index.sortedTasks
based on enqueue time.currTime
to 0 and an empty min-heap nextTask
.sortedTasks
or nextTask
.
a. If nextTask
is empty and the next task's enqueue time is greater than currTime
, update currTime
to the next task's enqueue time.
b. Add all tasks available at currTime
to nextTask
.
c. Pop the task with the shortest processing time from nextTask
, process it, and add its index to the result.
d. Increment currTime
by the processing time of the processed task.