Medium data structure and algorithm practice puzzle.
Given a network as an adjacency list, return how many separate pieces it has broken into. One is healthy. Two or more is a partition, and it is the failure that makes distributed systems hard, because each piece is still working perfectly and has no way to tell whether the other half is down or merely unreachable. The answer is a count of connected components, which is one traversal per unvisited router and an outer loop that most people leave out.
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