← Bank of America Interview Insights
I knew this type of puzzle but blanked on the clean setup for a second.
Recognize that the last prisoner in line can see all hats in front and can use their guess to encode parity information for the others. The remaining prisoners can then deduce their own hat color by combining the parity with the hats they see in front. This guarantees 99 correct guesses, with the last prisoner having a 50% chance.
Pro tip: Mention that the strategy uses the last prisoner as a 'sacrificial' information carrier, and that the parity can be either even or odd red hats—agree on one beforehand. This shows you understand the trade-off between individual certainty and group optimization.
Confirm that prisoners can hear previous guesses and that they agree on a strategy beforehand. Also note that the last prisoner sees all 99 hats in front.
Decide that the last prisoner will say 'red' if the number of red hats they see is even, and 'blue' if odd (or vice versa). This encodes the parity of red hats among the first 99.
Each subsequent prisoner counts the red hats they see in front. If the parity of that count matches the announced parity, their own hat is blue; otherwise, it's red.
Show that each prisoner from the 99th to the 1st can correctly guess their hat. The last prisoner's guess may be wrong, but all others are guaranteed correct.
Conclude that at least 99 prisoners can be guaranteed to guess correctly, and the 100th has a 50% chance, so the maximum guaranteed number is 99.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.