Schedule Ready Tasks by Deadline
Company: Scale AI
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of task scheduling and dependency management in directed acyclic graphs, along with algorithmic selection and data-structure-based optimization for repeated minimum-deadline retrieval.
Part 1: Earliest Deadline Task Without Dependencies
Constraints
- 0 <= len(tasks) <= 100000
- `task_id` values are unique integers
- `deadline` is an integer in the range [-10^9, 10^9]
Examples
Input: [(101, 5), (102, 2), (103, 8)]
Expected Output: 102
Explanation: Task 102 has the smallest deadline: 2.
Input: [(3, 4), (1, 4), (2, 6)]
Expected Output: 1
Explanation: Tasks 3 and 1 tie on deadline 4, so return the smaller task_id: 1.
Input: [(7, 10)]
Expected Output: 7
Explanation: Only one task is present.
Input: []
Expected Output: None
Explanation: Empty input has no task to return.