Scale AI·Software Engineer·Technical Phone Screen
- Design a TaskScheduler with an AddTasks method (each task has an id, deadline, and list of subtasks) and a ConsumeTask method that returns the task with the earliest deadline, or 'no task' if none exist.
- Now extend the scheduler so that each task's subtasks field represents prerequisites. ConsumeTask should only return tasks whose prerequisites have all been consumed already. How do you maintain this efficiently?
“The first part felt fine.”