Course Schedule

Graphs · cycles · Track visiting and visited states · Stretch · about 28 min

Why it matters

Cycle detection models real dependency systems, not only interview graphs.

How it connects

A graph path asks “can I get there?” Now the question is whether prerequisites loop back forever.

Try first

What does it mean if DFS reaches a course that is already on the current path?

Interview cue

The visiting state represents the current dependency chain, which is exactly where a cycle appears.