Build the adjacency list and in-degree array from relations. For each , add edge and increment indegree[next].
Initialize finishTime[i] = time[i] for every course. Courses with no prerequisites finish in time[i] months.
Push all courses with into the queue and run Kahn's algorithm.
When processing course , for each neighbor : set finishTime[v] = max(finishTime[v], finishTime[u] + time[v]). This propagates the earliest start.
The answer is max(finishTime[i]) over all courses. This runs in time and uses space.