Hard data structure and algorithm practice puzzle.
Given a wait-for graph as an adjacency list, where an edge from A to B means A is blocked holding something B wants, return whether the system is deadlocked. A deadlock is exactly a cycle: every process in it is waiting for a process that is waiting, and none will ever run again. Peel off everything that is waiting for nothing, then everything that only waited on those, and if anything is left over it is the cycle.
Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free.
Browse all 536 puzzles