indegree
to keep track of the number of prerequisites for each course.maxTime
to keep track of the minimum time needed to complete each course.u
.
b. For each neighbor v
(course that has u
as a prerequisite):
i. Update maxTime[v]
to be the maximum of its current value and maxTime[u] + time[v-1]
.
ii. Decrement the indegree of v
.
iii. If the indegree of v
becomes zero, enqueue v
.maxTime
as the result.