FastPrepBounded Word Guess Solver
Problems/Bounded Word Guess Solver

Bounded Word Guess Solver

Atlassian logoAtlassian● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report specifies an adaptive solver that chooses the first remaining potential secret, checks feedback and filters the list after each guess. This practice method simulates the feedback oracle and returns whether the solver succeeds within its budget. Bounds, duplicate handling and repeated-letter allocation are stated practice rules.

Simulate a Wordle-style solver for a five-letter secret. Its ordered list potentialSecrets contains the true secret. The solver may make at most maxGuesses guesses.

  1. Choose the first word in the current list of potential secrets.
  2. If that guess equals the secret, return true.
  3. Otherwise, generate five-character G/Y/X feedback against the secret. G means an exact position match, Y means an unmatched copy exists elsewhere, and X means no copy remains.
  4. Keep only words that would produce exactly the same feedback for this guess if they were the secret. Keep their original order, then repeat.

For this exercise, assume feedback assigns all exact matches first, then assigns yellow matches from left to right using each remaining secret letter at most once. Duplicate list entries are allowed and keep their order when retained.

Return false when the attempt budget ends before the solver guesses the secret. A zero budget makes no guesses. The supplied secret lets the practice runner simulate feedback; the choice of each guess must depend only on the current potential list, not on looking up the secret directly.

Complete canSolveWithinGuesses(secret, potentialSecrets, maxGuesses). Model the list and attempt budget as solver state, and reuse a feedback helper for both observed and hypothetical feedback.

Function

canSolveWithinGuesses(secret: String, potentialSecrets: String[], maxGuesses: int) → boolean

Examples

Example 1

secret = "house"potentialSecrets = ["crane","mould","house"]maxGuesses = 2return = true

The first guess is crane, which gives XXXXG against house. Mould would give XXXXX for crane, so it is removed. House is the only remaining word, and the second guess succeeds.

Example 2

secret = "house"potentialSecrets = ["crane","stole","house"]maxGuesses = 2return = false

The first guess crane gives XXXXG. Both stole and house produce that feedback for crane, so both remain in that order. The second guess is stole, which gives YXYXG against house. The budget ends before the solver can guess house.

Example 3

secret = "apple"potentialSecrets = ["apple"]maxGuesses = 0return = false

A zero budget permits no guesses, even when the secret is the first potential word.

Constraints

  • secret.length == 5.
  • 1 <= potentialSecrets.length <= 1000.
  • Every potential word has length 5.
  • The secret and every potential word contain only lowercase English letters.
  • The secret occurs in potentialSecrets.
  • 0 <= maxGuesses <= 100000.

More Atlassian problems

  • Deterministic Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Generate Word Guess FeedbackONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
All Atlassian interview questionsSee Atlassian hiring insights
Saved
public boolean canSolveWithinGuesses(String secret, String[] potentialSecrets, int maxGuesses) {
    // Write your code here.
}
Checking account…