Complete as Many Deadline-Bounded Courses as Possible
Company: SuperMoney
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Other
### Problem
Each course is [duration,lastDay]. Start on day one, take one course at a time continuously, and finish every chosen course on or before its lastDay. Return the maximum number of courses that can be completed.
```cpp
class Solution {
public:
int scheduleCourse(vector<vector<int>>& courses);
};
```
### Examples
**Example 1:**
```text
courses = [[3,3],[2,4],[1,5]]
Output: 2
Explanation: The durations 2 and 1 can finish on days 2 and 3; all three need six days.
```
**Example 2:**
```text
courses = [[2,2],[1,3],[2,5]]
Output: 3
Explanation: The given order completes on days 2, 3 and 5.
```
### Constraints
- The list contains 1..10000 courses. Both duration and lastDay are integers in 1..10000.
### Clarifying Questions
Use inclusive deadlines and justify exchanging out the longest duration when a prefix overflows.
```hint Read the boundary condition
If one selected course must be dropped, which choice leaves the most capacity for future deadlines?
```
### Contract considerations
Use inclusive deadlines and justify exchanging out the longest duration when a prefix overflows.
Overview: Complete as Many Deadline-Bounded Courses as Possible. Each course is [duration,lastDay].
Complete as Many Deadline-Bounded Courses as Possible
SuperMoney
Sep 11, 2026
hardSoftware EngineerOtherCoding & Algorithms
0
0
Problem
Each course is [duration,lastDay]. Start on day one, take one course at a time continuously, and finish every chosen course on or before its lastDay. Return the maximum number of courses that can be completed.
class Solution {
public:
int scheduleCourse(vector<vector<int>>& courses);
};
Examples
Example 1:
courses = [[3,3],[2,4],[1,5]]
Output: 2
Explanation: The durations 2 and 1 can finish on days 2 and 3; all three need six days.
Example 2:
courses = [[2,2],[1,3],[2,5]]
Output: 3
Explanation: The given order completes on days 2, 3 and 5.
Constraints
The list contains 1..10000 courses. Both duration and lastDay are integers in 1..10000.
Clarifying Questions Guidance
Use inclusive deadlines and justify exchanging out the longest duration when a prefix overflows.
Contract considerations
Use inclusive deadlines and justify exchanging out the longest duration when a prefix overflows.