The Guess the Word interview question is a Mastermind-style game. You are given a list of 6-letter words. One is the secret word. You have an API guess(word) that returns the number of exact matches (same character in the same position) between your guess and the secret word. You have 10 allowed guesses to find the secret word.
Companies like Google and Dropbox ask this Game Theory and Interactive problem to evaluate your ability to design a heuristic strategy. There is no algorithm that guarantees a win 100% of the time in 10 guesses under all conditions, but you must implement a "Minimax" or "Elimination" strategy that maximizes the probability of winning. It tests your ability to filter search spaces based on feedback.
This problem relies on a Search Space Elimination / Minimax pattern.
match_count from the API.match_count == 6, you win.match_count matches with your guessed word. Discard all words in the list that don't satisfy this.Words: ["acckzz", "ccbazz", "eiowzz", "abcczz"]. Secret: "acckzz".
"ccbazz". API returns 3 (because 'z', 'z', and one other char might align, wait: c-c, c-c, b-c, a-k, z-z, z-z. No, only 'z', 'z' align. Match = 2)."ccbazz".
"acckzz" matches "ccbazz" in 2 positions ('z', 'z'). Keep."eiowzz" matches in 2 positions ('z', 'z'). Keep."abcczz" matches in 2 positions ('z', 'z'). Keep."eiowzz". API returns 2."eiowzz" with match 2.
"acckzz" has 2 matches. Keep."abcczz" has 2 matches. Keep.match_count matches instead of exactly match_count matches.The core logic here is identical to "Wordle." The feedback you receive is a strict constraint. If you guessed "APPLE" and got 0 matches, the secret word cannot contain A, P, L, or E in those positions. Filtering the candidate pool is the key.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find the Divisibility Array of a String | Medium | Solve | |
| Guess the Majority in a Hidden Array | Medium | Solve | |
| Stone Game III | Hard | Solve | |
| Stone Game V | Hard | Solve | |
| Verbal Arithmetic Puzzle | Hard | Solve |