← Bank of America Interview Insights

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

Intermediate
Jun 2026

Summary

Short technical screen for a quant engineer role, basically just one puzzle-style question with a follow-up that scaled the problem up.

Questions Asked (1)

Q1

There are prisoners wearing hats of k different colors (generalized from 2). Each prisoner can see all other hats but not their own. They must simultaneously guess their own hat color. What strategy maximizes the number of correct guesses?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

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.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Clarify the problem

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.

2. Identify the invariant

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.

3. Design the strategy

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.

4. Prove optimality

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.

5. Discuss trade-offs

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.

Key Points to Mention

  • Modular arithmetic over k colors
  • Pre-agreed strategy without communication
  • Worst-case guarantee of exactly one correct guess
  • Optimality proof using adversary argument
  • Comparison with probabilistic strategies for expected value
  • Application to distributed systems and error-correcting codes

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