FastPrepGuess the Word
Problems/Guess the Word

Guess the Word

Google logoGoogle● HardNEW GRADOAPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand report points straight to the interactive Guess the Word problem. We use a fixed minimax policy and let a batch simulator see the hidden word. That way the same feedback and filtering task can be checked without an interactive callback.

You are given an array words of distinct six-letter lowercase words and a secret word that appears in words.

A guess receives the number of positions whose letters exactly match secret. Simulate the following solver for at most 10 guesses:

  1. Start with every word as a possible secret.
  2. For each possible guess among the current candidates, group the current candidates by the feedback they would give, from 0 through 6.
  3. For each guess, find the size of its largest group. Choose the guess with the smallest such size. Break ties by lexicographically smaller word.
  4. If all six positions match, return the one-based guess number. Otherwise retain only candidates with the observed feedback and continue.

Return -1 if this solver does not guess secret within ten attempts.

Function

guessesToFindSecret(words: String[], secret: String) → int

Examples

Example 1

words = ["acckzz","ccbazz","eiowzz","abcczz"]secret = "acckzz"return = 1

The minimax rule chooses acckzz first because every feedback bucket has size at most one.

Example 2

words = ["acckzz","ccbazz","eiowzz","abcczz"]secret = "eiowzz"return = 2

The first guess acckzz receives feedback 2, leaving only eiowzz, which is guessed next.

Example 3

words = ["aaaaaa","bbbbbb","cccccc"]secret = "cccccc"return = 3

Every distinct pair has feedback zero, so lexicographic tie-breaking guesses aaaaaa, then bbbbbb, then cccccc.

Constraints

  • 1 <= words.length <= 100.
  • Every word has exactly six lowercase English letters.
  • All words are distinct.
  • secret appears in words.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Balance a Chemical EquationMicrosoft · OA
  • Binary CircuitAkuna Capital · OA
  • Parse, Normalize, and Combine PolynomialsSquarepoint Capital · PHONE SCREEN
  • Minimum Numeric Code TransformationAdobe · OA
  • Good SubsequencesNutanix · OA
  • Break a PalindromeRoblox · OA
  • Minimize Expression with ParenthesesPinterest · OA
  • Signed Digit Partitions Reaching a TargetMeta · PHONE SCREEN
  • String Transformation (Also for Infra Automation Intern)Snowflake · OA
  • Sum of All ValuesFlexport · OA
See Google hiring insights
Saved
class Solution {
    public int guessesToFindSecret(String[] words, String secret) {
        // Write your code here.
    }
}
Checking account…