← Bank of America Interview Insights

Bank of America·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Quant engineer screen with a classic probability brainteaser. Short and focused, just the one puzzle as far as I could tell.

Questions Asked (1)

Q1

100 prisoners stand in a line, each wearing a randomly assigned red or blue hat. Every prisoner can only see the hats of the people in front of them. What is the maximum number of prisoners you can guarantee will guess their own hat color correctly?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I knew this type of puzzle but blanked on the clean setup for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Clarify the setup

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.

2. Define the parity encoding

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.

3. Deduce individual hat colors

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.

4. Verify correctness

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.

5. State the guarantee

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.

Key Points to Mention

  • Parity (even/odd) of red hats as the encoding mechanism
  • The last prisoner sacrifices their own certainty to provide information
  • Sequential deduction: each prisoner uses the parity and the hats they see
  • The strategy works regardless of the random hat assignment
  • Maximum guaranteed correct guesses is 99, not 100
  • This is a classic information theory and strategy problem

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.