Course Schedule III
There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [durationi, lastDayi] indicates that the i^th course should be taken continuously for durationi days and must be finished before or on lastDayi.
You will start on the 1^st day and you cannot take two or more courses simultaneously.
Return the maximum number of courses that you can take.
Example 1
Input
courses = [[100,200],[200,1300],[1000,1250],[2000,3200]]Output
3You can take the 1^st course, then the 3^rd course, then the 2^nd course, but the 4^th course would finish after its closing date.
Example 2
Input
courses = [[1,2]]Output
1The only course can be completed before or on its last day.
Constraints
- 1 <= courses.length <= 10^4
- 1 <= durationi, lastDayi <= 10^4