Medium data structure and algorithm practice puzzle.
Given the sorted positions of nodes on a hash ring and a key's position, return the position of the node that owns it: the first one at or after the key, wrapping past the end to the first node. The point of the ring is what happens when a node leaves: only its own slice moves, instead of every key rehashing because the modulus changed. Finding the owner is a lower bound, and the wrap is the one case that separates a working ring from one that drops the highest keys.
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