Choose the Next Hidden-Word Guess
Reported by candidates from Flexport's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Flexport reportedly put a word-guessing problem in front of candidates in July 2026, and it looks fancy until you strip it down. It reduces to filter a list, then brute-force a minimax over pairwise positional match counts. No entropy math, no clever search. If you've got an OA invite and 48 hours, this one is mostly careful bookkeeping on strings. The risk isn't the idea, it's the details: which words you score against, and the tie-break. StealthCoder sits as a safety net on the live OA if you blank, but the logic here is short enough to hold in your head.
The problem
A hidden target word is guaranteed to be one of the unique strings in words. Every word has the same length. For two words a and b, their match score is the number of indices i for which a[i] == b[i]. For example, the score between aabbcc and abcdef is 1. You have already made the guesses in guesses. The corresponding value scores[i] is the match score returned for guesses[i] against the hidden target. First, keep only the words that are consistent with every previous guess and score. These are the remaining candidates. Minimax selection Choose the next guess from the remaining candidates using this rule: For a possible guess, group every remaining target candidate by the score it would return. Measure the guess by the size of its largest group. Choose the guess whose largest group is as small as possible. If several guesses tie, return the lexicographically smallest one. Return the chosen next guess. What the interview report shared The report described an onsite word-guessing variant. The target is in the supplied word list, guesses must come from that list, and feedback counts positions where both the character and index match. The goal is to identify the target with as few calls as possible, and the report mentioned an entropy-style idea. It did not provide an exact function signature, constraints, or tie-breaking rule. Function chooseNextWordGuess(words: String[], guesses: String[], scores: int[]) → String Examples Example 1 words = ["acckzz","ccbazz","eiowzz","abcczz"] guesses = [] scores = [] return = "acckzz" Using acckzz would produce scores 6, 3, 2, and 4 for the four possible targets. Every score group has size 1, so its worst group is smaller than that of any other candidate. Example 2 words = ["acckzz","ccbazz","eiowzz","abcczz"] guesses = ["acckzz"] scores = [3] return = "ccbazz" Among the listed words, only ccbazz has exactly three positional matches with acckzz. It is therefore the only remaining target candidate and must be returned. Example 3 words = ["aaaa","aaab","aaba","abaa","baaa"] guesses = [] scores = [] return = "aaab" Guessing aaaa puts the other four words into one score-3 group, so its worst group has size 4. Each of the other four guesses has a worst group of size 3; aaab is lexicographically smallest among them. Constraints 1 <= words.length <= 500 1 <= words[i].length <= 20 All strings in words are unique, contain only lowercase English letters, and have equal length. 0 <= guesses.length == scores.length < words.length Every value in guesses appears in words. 0 <= scores[i] < words[i].length, so the target has not already been found. At least one word is consistent with all previous guesses and scores.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Step one: filter. For each word w in words, keep it only if score(w, guesses[i]) == scores[i] for every i. That's your candidate set. Step two: for each candidate g, count how many candidates produce each score against g using a small array or hash map, take the max bucket size, and keep the g with the smallest max. On ties, take the lexicographically smaller string. With 500 words and length 20, the O(n^2 * L) cost is about 5 million character comparisons, which is fine. The common pitfall is picking guesses from all of words instead of only the remaining candidates, as the problem states. Another is counting g against itself, which gives a full-length score bucket of size 1 and is correct to include. The entropy talk in the report is noise. Example 3 confirms the tie-break: aaab beats the others at worst-group size 3. StealthCoder is the hedge if the live OA changes a detail and you freeze.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Choose the Next Hidden-Word Guess cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as guess the word. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Flexport's OA.
Flexport reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Choose the Next Hidden-Word Guess FAQ
What's the trick in the Flexport next-guess problem?+
Filter first, then brute force. Keep words whose positional match score against each past guess equals the recorded score. Then for each remaining candidate, bucket all candidates by score and take the largest bucket. Pick the smallest largest bucket, ties broken lexicographically. No entropy needed.
How hard is this really?+
Easy to medium. The algorithm is a double loop with a helper that counts matching indices. The difficulty is reading the spec carefully, since it's long and the report was vague. If you code the filter and minimax as two clean functions, it goes fast.
Should the next guess come from all words or only candidates?+
Only the remaining candidates. The statement says to choose the next guess from the remaining candidates. Example 2 shows this too, where only one candidate survives and gets returned. Scoring against all words is a classic way to fail hidden tests.
Will 500 words and length 20 time out with brute force?+
No. Comparing every pair of candidates costs roughly 500 * 500 * 20, about 5 million character checks. That's fine in any mainstream language. Skip precomputation tricks unless you want them. A simple score function inside nested loops is enough.
How do I prepare for this in 48 hours?+
Write the score function and the filter from memory, then do the minimax loop on the three examples by hand. Check the tie-break on example 3. Practice similar string-comparison and counting problems for an hour, and keep your code small so edge cases stay visible.