Description
Given n courses, prerequisite relations, and time to complete each course, return minimum time to complete all courses working in parallel.
Examples
Input:
n = 3, relations = [[1,3],[2,3]], time = [3,2,5]Output:
8Explanation:
3+5 = 8.
Input:
n = 3, relations = [[1]], time = [3,2,5]Output:
1Explanation:
Minimal case with a single-element matrix.
Input:
n = 5, relations = [[1,2],[1,3],[2,4],[3,4],[4,5]], time = [4,3,6,2,5]Output:
14Explanation:
The minimum time to complete all courses is 14, determined by the longest path through the dependency graph.
Constraints
- •
1 ≤ n ≤ 5 × 10⁴