← Bank of America Interview Insights

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

Senior
Apr 2026

Summary

Quant engineer interview with a classic combinatorics/probability puzzle. Just the one question from what I can tell, but it was enough to chew on for a while.

Questions Asked (1)

Q1

There are 7 prisoners, each wearing a hat of one of 7 possible colors. Every 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 knew this was some kind of modular arithmetic thing the moment they said 7 prisoners and 7 colors, but getting from that intuition to an actual clean strategy took me longer than I'd like to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., whether prisoners can communicate beforehand, if they must guess simultaneously, and if wrong guesses are allowed). Then, identify the core mathematical structure: this is a modular arithmetic problem where each prisoner computes a sum modulo 7 and uses a pre-agreed offset. Finally, present the strategy clearly, emphasizing that exactly one prisoner will guess correctly.

Pro tip: Demonstrate awareness of practical constraints: in a real system, communication and synchronization are costly, so the pre-agreed strategy must be simple and robust. Also, mention that this problem illustrates error-correcting codes and distributed consensus, which are relevant to banking systems.

1. Clarify assumptions

Ask whether prisoners can agree on a strategy beforehand, whether they guess simultaneously, and whether wrong guesses have consequences. This ensures you understand the problem fully.

2. Model the problem mathematically

Assign each color a number 0–6. Each prisoner sees the sum of all other hats modulo 7. The goal is to ensure at least one prisoner guesses correctly.

3. Devise the strategy

Prisoners agree that prisoner i will guess that the total sum modulo 7 equals i. Then prisoner i computes their guess as (i - sum_of_others) mod 7. Exactly one prisoner will have the correct total sum, so exactly one will guess correctly.

4. Verify correctness

Show that if the actual total sum modulo 7 is S, then prisoner S will guess correctly, and all others will guess wrong. Thus, at least one correct guess is guaranteed.

5. Discuss extensions and trade-offs

Mention that this strategy generalizes to n prisoners and n colors, and discuss trade-offs such as the need for pre-agreement and the fact that only one prisoner needs to be correct.

Key Points to Mention

  • Modular arithmetic and the pigeonhole principle
  • Pre-agreed strategy and communication assumptions
  • Guarantee of exactly one correct guess
  • Generalization to n prisoners and n colors
  • Relevance to error-correcting codes and distributed systems
  • Trade-offs: simplicity vs. optimality, and practical constraints in real-world systems

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