Build adjacency lists, detect cycles with DFS, and find valid course orderings
Haven't done Part 1? Start with DFS grid exploration first
Watch DFS cycle detection step-by-step with adjacency lists
Convert an edge list into an adjacency list for a directed graph.
Detect cycles in a prerequisite graph using DFS with three-color marking.
Find a valid course order using topological sort (DFS or Kahn's algorithm).