Find secret word with match-count feedback
GoogleSoftware Engineer · Technical ScreenLast updated
This question evaluates algorithmic reasoning and inference from constrained feedback, testing skills in information-theoretic deduction, pattern matching, and search strategy within a bounded-query interactive setting.
Problem
You are given a list of unique lowercase words, all of the same length (e.g., length = 6). One of these words is a secret word.
You can interact with a black-box API:
matchCount(guess) -> int: when you submit a wordguessfrom the list, the API returns the number of positionsisuch thatguess[i] == secret[i](i.e., exact character match at the same index).
You are allowed to call matchCount at most 10 times.
Task
Design/implement a function (e.g., findSecretWord(words)) that uses the API to identify the secret word within the guess limit.
Notes / Constraints
wordscontains between 1 and 100 words.- All words have equal length
L(commonlyL = 6). - Every guess must be a word from
words. - After each API response, you may adapt your next guess.
What to return
Depending on the interface, you may either:
- return the identified secret word, or
- stop once
matchCount(guess) == L(found it).
(Your interviewer may treat this as an interactive problem; focus on strategy + correctness under the 10-guess constraint.)
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.