Hard data structure and algorithm practice puzzle.
Given a routing trie and a destination address as a list of bits, return the next hop of the most specific route that matches, or 0 when nothing does. A node holds a next-hop id when a route ends there and 0 when it is only a branch. Walk down taking the left child on a 0 bit and the right on a 1, remembering the last real route you passed, and the last one you remember is the longest prefix. This is the single operation every packet on the internet goes through, and it is why a routing table is a tree rather than a list.
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