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 word
guess
from the list, the API returns the number of positions
i
such that
guess[i] == secret[i]
(i.e., exact character match at the same index).
You are allowed to call matchCount at most 10 times.
Design/implement a function (e.g., findSecretWord(words)) that uses the API to identify the secret word within the guess limit.
words
contains between 1 and 100 words.
L
(commonly
L = 6
).
words
.
Depending on the interface, you may either:
matchCount(guess) == L
(found it).
(Your interviewer may treat this as an interactive problem; focus on strategy + correctness under the 10-guess constraint.)