Skip to content

Commit 6083e23

Browse files
committed
Add 210 note
1 parent 2fde3ef commit 6083e23

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## 210. Course Schedule II (Medium)
2+
3+
### **链接**
4+
题目:https://leetcode.com/problems/course-schedule-ii/
5+
代码(github):https://github.com/illuz/leetcode
6+
7+
### **题意**
8+
学习课程 A 要先学课程 B,给出一些课程学习顺序,给出学完这些课程的全部顺序。
9+
10+
### **分析**
11+
[207](https://github.com/illuz/leetcode/tree/master/solutions/207.Course_Schedule) 一样拓扑排序,不过要记录路径。
12+
13+
1. 用栈,只要每次记一下节点就行了。
14+
2. 用 dfs,不能跟 207 一样直接一个一个 check 过去。先找出入度为 0 的节点,再 dfs 过去。dfs 中每个节点处理完子节点后再把自己节点加到路径中,这样就维护了一个倒序的路径,最后把这个路径反向一下就行了。
15+
16+
资料:[Topological sorting](https://en.wikipedia.org/wiki/Topological_sorting)

0 commit comments

Comments
 (0)