LeetCode 843. Guess the Word

Tsotne Chakhvadze
1 min readFeb 19, 2022

--

After a long time, I’m finally back and I hope I’ll be able to post LeetCode solutions much often.

Yes I mentioned before that C++ is the best programming language for solving DSA problems, but that particular problem, I think would be solved in Python much easier (corresponding code there would be much less).

Problem Statement:
This is an interactive problem.
You are given an array of unique strings wordlist where wordlist[i] is 6 letters long, and one word in this list is chosen as secret.

You may call Master.guess(word) to guess a word. The guessed word should have type string and must be from the original list with 6 lowercase letters.

This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word. Also, if your guess is not in the given wordlist, it will return -1 instead.

For each test case, you have exactly 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or fewer calls to Master.guess and at least one of these guesses was secret, then you pass the test case.

--

--

Tsotne Chakhvadze

Hidden OP character in my own manga/anime life. Maybe you know me as Software engineer