Course Schedule, solved two ways

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Recursion tree

not called yet running now paused, waiting on a child returned True done earlier, reused returned False / cycle

Call stack

Graph

state

needs

0 · unvisited 1 · on the current path 2 · done (finishable) cycle

Keyboard: ← → step, Space play or pause. Up to 8 courses and 16 pairs. Both solutions are O(V + E). DFS answers "is there a cycle?" directly; Kahn's answers "can I build a full order?" and gives you that order for free. Switching solution keeps the current input.