Medium data structure and algorithm practice puzzle.
Given objects as an adjacency list of references and a set of roots, return how many objects are unreachable and can be freed. Reachability from the roots is the whole definition of live, and it is why mark and sweep collects a cycle of objects that point only at each other while reference counting never can: the cycle keeps its own counts above zero forever, and no root can reach it.
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