Course Schedule
Course Schedule II (LC.210)
Example
Input: 4, [[1,0],[2,0],[3,1],[3,2]]
Output: [0, 1, 2, 3] or [0, 2, 1, 3]Analysis
Approach
Step 1 Build a graph
Step 2 topo sort with BFS
- count indegree
- put 0 indegree (no incoming edges) to queue
- delete that node from the queue and all its outgoing edges (decrease the indegree of its neighbor)Clear Version
Short Version
Last updated