Skip to content

Practice Course Schedule III

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#630
LeetCode Problem

Course Schedule III

Problem Statement

There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicate that the ith course should be taken continuously for durationi days and must be finished before or on lastDayi. You will start on the 1st day and you cannot take two or more courses simultaneously. Return the maximum number of courses that you can take.

Source: Course Schedule III on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
courses = [[100,200],[200,1300],[1000,1250],[2000,3200]]
Output
3

# Example 2

Input
courses = [[1,2]]
Output
1

# Example 3

Input
courses = [[3,2],[4,3]]
Output
0

Constraints

1 <= courses.length <= 10^4
1 <= durationi, lastDayi <= 10^4

Related LeetCode Problems

Practice more problems similar to Course Schedule III.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.