← Questions

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

0
Scale AICodingLast asked May 2026

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.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding