← Bank of America Interview Insights

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

Senior
May 2026

Summary

Quant engineer interview with a classic combinatorics/probability puzzle. One question, pretty clean, but the solution space is deeper than it looks if you haven't seen this type before.

Questions Asked (1)

Q1

There are 7 prisoners and 7 possible hat colors. Each prisoner can see everyone else's hat but not their own. If at least one prisoner correctly guesses their own hat color, all go free. What is the optimal strategy?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I'd seen hat puzzle variants before but not this exact setup, so I spent the first minute just restating the problem back to myself out loud which probably looked weird.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the rules: each prisoner sees all other hats, and they must all guess simultaneously or can they strategize beforehand? Then, recognize that with 7 colors and 7 prisoners, a modular arithmetic strategy can guarantee at least one correct guess. Explain the strategy: assign each color a number 0-6, each prisoner computes the sum of the other hats modulo 7, and guesses the color that would make the total sum equal to their assigned number.

Pro tip: Mention that this is a classic error-correcting code problem: the strategy ensures exactly one prisoner guesses correctly, and it's optimal because no strategy can guarantee more than one correct guess when all guesses are simultaneous.

1. Clarify the rules and constraints

Ask if prisoners can communicate after seeing hats, if guesses are simultaneous, and if they can agree on a strategy beforehand. Assume they can strategize beforehand and guesses are simultaneous.

2. Identify the goal and success condition

The goal is to guarantee at least one correct guess. With 7 colors and 7 prisoners, a deterministic strategy can ensure exactly one correct guess.

3. Assign numbers to colors and prisoners

Number the colors 0 through 6. Assign each prisoner a unique number from 0 to 6 (e.g., prisoner i gets number i).

4. Define the guessing strategy

Each prisoner computes the sum of the colors they see modulo 7. They guess the color that would make the total sum of all hats congruent to their assigned number modulo 7.

5. Prove correctness and optimality

Show that the actual total sum modulo 7 equals exactly one prisoner's assigned number, so that prisoner guesses correctly. Also argue that no strategy can guarantee more than one correct guess because the total sum is unknown to any single prisoner.

Key Points to Mention

  • Modular arithmetic (mod 7) is key to the strategy.
  • Each prisoner is assigned a unique residue class modulo 7.
  • The sum of all hats modulo 7 will match exactly one prisoner's assigned number.
  • The strategy guarantees exactly one correct guess, which is optimal.
  • This is analogous to error-correcting codes or covering codes.
  • Communication and simultaneity assumptions must be clarified.

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