Problems > Deadlock Detection > Editorial

Deadlock Detection — Solution & Editorial

Back to the Problem

Kahn's algorithm: repeatedly remove in-degree-0 nodes; if fewer than N get removed, the remainder forms a cycle. (DFS with colors is the classic alternative.)

Complexity: O(N + M)