返回题库

并行课程 III

Parallel Courses III

专题
Algorithmic Programming / 算法编程
难度
L4
来源
Citadel

题目详情

问题:并行课程 III

考察:数组、动态规划、图

来源:DSA Prep / Citadel

链接:https://leetcode.com/problems/parallel-courses-iii

英文原题

Problem: Parallel Courses III

Patterns: Array, Dynamic Programming, Graph

Recency: 6mo

Link: https://leetcode.com/problems/parallel-courses-iii

Source: https://www.dsaprep.dev/blog/citadel-coding-interview-questions/

解析

思路:课程依赖形成 DAG。对入度为 0 的课程入队,拓扑过程中维护完成每门课的最早时间;访问后继时用当前完成时间加后继耗时更新。

复杂度:时间 O(V+E),空间 O(V+E)。


英文解析

Approach: This is longest path on a DAG. Topologically process prerequisites and let `finish[v]` be the earliest completion time of course `v`; update neighbors with `finish[v] + time[neighbor]`.

Complexity: Time O(n+e)O(n+e), space O(n+e)O(n+e).