Compute worst-case guesses for adaptive hangman
Company: Dropbox
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates algorithmic problem-solving, combinatorial reasoning, and adversarial information-theoretic thinking by requiring modeling of worst-case query strategies for adaptive letter-guessing.
Constraints
- words are distinct lowercase strings of the same length
- len(words) is small enough for minimax over states
Examples
Input: (['aa'],)
Expected Output: 0
Explanation: One candidate is already identified.
Input: (['ab', 'cd'],)
Expected Output: 1
Explanation: One distinguishing guess is enough.
Input: (['cat', 'car', 'bar'],)
Expected Output: 2
Explanation: The first guess can split but the host chooses the largest remaining group.
Input: (['aaa', 'bbb', 'ccc', 'abc'],)
Expected Output: 2
Explanation: Small adversarial partitioning case.
Hints
- Partition candidates by the revealed positions for a guessed letter.
- Use memoization on the candidate set and guessed letters.