Rainbow Hats
Medium logic-puzzles interview practice: Rainbow Hats.
N people enter a room and each receives a hat labeled with a number from 0 to N-1 (duplicates allowed). Each person sees others' hats but not their own. Everyone simultaneously guesses their number. What strategy guarantees at least one correct guess?