Hard data structure and algorithm practice puzzle.
Given a forwarding table where next[i] is the router that i sends packets to, or -1 when i delivers them locally, return whether any packet can circle forever. Each router has exactly one next hop, which makes this a functional graph and means a loop is the only way a packet fails to arrive. Colour each router while you walk it and finish it when the walk completes: meeting a router that is still being walked is the loop, and meeting a finished one is not.
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