630. Course Schedule III

Practice Course Schedule III for free on NudgeCode: Hard, Heap pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Each courses[i] = [duration, lastDay] is a course that takes duration consecutive days and must be finished on or before day lastDay. You start on day 1 and can take only one course at a time. Return the maximum number of courses you can take.

Example

courses = [[100,200],[200,1300],[1000,1250],[2000,3200]]  ->  3
courses = [[1,2]]                                         ->  1
courses = [[3,2],[4,3]]                                   ->  0

Constraints