← Bank of America Interview Insights
The 2-color version I'd seen before so I felt okay, but when they pushed it to k colors I had to actually think.
First, clarify the problem constraints: simultaneous guesses, no communication after hats are assigned, and prisoners can agree on a strategy beforehand. Then, explain that the optimal strategy uses modular arithmetic over the k colors, ensuring exactly one prisoner guesses correctly in the worst case, which maximizes the guaranteed number of correct guesses to at least one.
Pro tip: Emphasize that the strategy is deterministic and requires no communication during the game, which is crucial for real-world distributed systems where coordination is limited.
Confirm that prisoners guess simultaneously, cannot see their own hat, and can agree on a strategy beforehand. Also, clarify whether the goal is to guarantee a minimum number of correct guesses or to maximize the expected number.
Recognize that the sum of all hat colors modulo k is a fixed value unknown to any prisoner. Each prisoner can compute the sum of the other hats modulo k and deduce what their own hat color must be to make the total sum equal to a pre-agreed value.
Assign each prisoner a unique target residue modulo k (e.g., prisoner i targets residue i). Each prisoner guesses the color that would make the total sum modulo k equal to their target residue. This ensures exactly one prisoner guesses correctly.
Show that no strategy can guarantee more than one correct guess in the worst case because the adversary can choose hat assignments to make all but one prisoner wrong. Thus, the strategy is optimal for the worst-case guarantee.
Mention that while this guarantees one correct guess, other strategies might maximize expected correct guesses if hat colors are randomly assigned. Compare worst-case vs. average-case performance.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.