Course Schedule (LC #207) asks if you can finish all courses given prerequisites. This is cycle detection in a directed graph. If there's a cycle, you can't finish. Use DFS with states: unvisited (), visiting (), visited (). When you enter a node, mark it visiting. When you finish all neighbors, mark it visited. If you reach a visiting node, there's a cycle. This runs in time and space. Course Schedule II (LC #210) returns a valid order using topological sort with the same DFS approach.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/graphs/course-schedule
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████