Given courses as [duration, lastDay] pairs (a course must be taken continuously and must finish on or before its lastDay), starting from day 1 and taking courses one at a time, return the maximum number of courses you can complete. The input is a JSON array of [duration, lastDay] pairs.
Input: A JSON array of [duration, lastDay] pairs.
Output: Integer — the maximum courses taken.
Input: [[100,200],[200,1300],[1000,1250],[2000,3200]]
Output: 3
Explanation: Three courses fit.Input: [[1,2],[2,3]]
Output: 2
Explanation: Both fit.Input: [[3,2],[4,3]]
Output: 0
Explanation: Neither fits its deadline.1<=n<=10^41<=duration,lastDay<=10^4