630. Course Schedule III
There aren
different online courses numbered from1
ton
. Each course has some duration(course length)t
and closed ondth
day. A course should be taken continuously fort
days and must be finished before or on thedth
day. You will start at the1st
day.
Givenn
online courses represented by pairs(t,d)
, your task is to find the maximal number of courses that can be taken.
Example:
Note:
The integer 1 <= d, t, n <= 10,000.
You can't take two courses simultaneously.
Thoughts:
Greedy:
sort course by end time, remove course by descending course length
Code (Python):
Last updated
Was this helpful?