Course Completion Time II
There are numCourses courses, prerequisite pairs [a, b] meaning b is a prerequisite of a, and time[c], how long course c takes. Under this rule a course may start as soon as any one of its prerequisites has finished — the others need not be done.
Return the earliest time by which every course is finished. Any number of courses can run at once, and the prerequisites contain no cycle.
anyPrerequisiteTime(3, [[2, 0], [2, 1]], [5, 1, 1]) -> 5
Course 2 starts when course 1 finishes at 1 and is done at 2; the whole set waits for course 0.
Hints
Hint 1
Same topological order as the all-prerequisites model, with the start time of a course being the minimum finish among its prerequisites instead of the maximum.
Hint 2
A course's finish time is only final once every prerequisite has been processed — that is why the relaxation runs in topological order, even though only the minimum matters.