Company: InMobi Glance IITKGP
Difficulty: medium
Course Schedule III Problem Description There are n different online courses, numbered from 1 to n . Course i is described by a pair [duration_i, lastDay_i] : it must be attended continuously for duration_i days, and it must be finished on or before day lastDay_i . You begin on day 1. You cannot attend two courses at the same time, so the courses you choose are taken one after another with no gaps and no overlaps. A course that starts on day s occupies days s through s + duration_i - 1 , so it finishes on day s + duration_i - 1 . Choose a set of courses and an order for them so that every chosen course finishes on or before its own last day. Print the largest number of courses such a schedule can contain. Input Format A single line holding the array courses written as [[d1,l1],[d2,l2],...,[dn,ln]] , where di is duration_i and li is lastDay_i . Whitespace inside the line is not significant. Output Format A single line holding one integer: the maximum number of courses that can be taken.