Skip to content

Practice Guess the Word

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#843
LeetCode Problem

Guess the Word

Problem Statement

One of the unique six-letter strings in words is secret. Each guess must be a six-letter entry from words. Use Master.guess(word) to identify it: the result is the number of characters matching the secret in both letter and position, or -1 for a word outside words. You must actually call Master.guess with the secret word within allowedGuesses calls. Merely identifying it without that call does not succeed. Inputs are chosen to permit success with a suitable strategy within the limit.

Source: Guess the Word on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
secret = "acckzz", words = ["acckzz","ccbazz","eiowzz","abcczz"], allowedGuesses = 10
Output
You guessed the secret word correctly.

# Example 2

Input
secret = "hamada", words = ["hamada","khaled"], allowedGuesses = 10
Output
You guessed the secret word correctly.

Constraints

1 <= words.length <= 100
words[i].length == 6
words[i] consist of lowercase English letters.
All the strings of words are unique.
secret exists in words.
10 <= allowedGuesses <= 30

Related LeetCode Problems

Practice more problems similar to Guess the Word.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.