Task scheduler that pops the earliest deadline once its subtasks are done
Implement a class with add_tasks(tasks) and consume_task(). Each task has an id, a deadline and a list of subtasks.
-
consume_taskreturns the task with the earliest deadline, or a "no task" result when empty. - A task may only be consumed after its subtasks are done; return the earliest-deadline task that is ready.
- Make both operations fast (for example with a heap) and give their complexity.
No answer yet. Write the first one; the best answer gets endorsed.
