Task scheduler that pops the earliest deadline once its subtasks are done

0
Remix

Implement a class with add_tasks(tasks) and consume_task(). Each task has an id, a deadline and a list of subtasks.

  1. consume_task returns the task with the earliest deadline, or a "no task" result when empty.
  2. A task may only be consumed after its subtasks are done; return the earliest-deadline task that is ready.
  3. Make both operations fast (for example with a heap) and give their complexity.
Scale AITechnical phone screenLast asked May 2026
No answer yet. Write the first one; the best answer gets endorsed.