We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2fde3ef commit 6083e23Copy full SHA for 6083e23
solutions/210.Course_Schedule_II/readme.md
@@ -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