Imagine you're playing a word guessing game similar to Mastermind, but with 6-letter words! You have an array of unique words words where each word is exactly 6 letters long. One of these words has been secretly chosen, and your job is to figure out which one it is.
You have access to a special Master object that can help you:
- Call
Master.guess(word)with any 6-letter word from the array - It returns
-1if the word isn't in the array - It returns the number of exact matches (same letter in the same position) between your guess and the secret word
The challenge? You have a limited number of guesses (allowedGuesses) to find the secret word. You need to be strategic - random guessing won't work!
Example: If the secret word is "acckzz" and you guess "ccbazz", you get 3 matches (positions 2, 4, and 5-6 match).
Your goal is to implement an intelligent strategy that can reliably find the secret word within the allowed number of guesses.
Input & Output
Visualization
Time & Space Complexity
For each guess, we need to evaluate all candidates and calculate partitions
Store candidates and partition information
Constraints
- 1 โค words.length โค 100
- words[i].length == 6
- words[i] consists of lowercase English letters
- All the strings of words are unique
- secret exists in words
- 10 โค allowedGuesses โค 30