Bounded Word Guess Solver
Problem statement
A solver has an ordered list of planned guesses and may make at most maxGuesses attempts. Return whether the secret word appears among the guesses the solver is allowed to make.
Stop after the first min(maxGuesses, guesses.length) entries. Repeated guesses still consume attempts.
Function
canSolveWithinGuesses(secret: String, guesses: String[], maxGuesses: int) → booleanExamples
Example 1
secret = "APPLE"guesses = ["CRANE","APPLE"]maxGuesses = 2return = trueOnly guesses inside the allowed prefix are considered.
Example 2
secret = "APPLE"guesses = ["CRANE","APPLE"]maxGuesses = 1return = falseOnly guesses inside the allowed prefix are considered.
Example 3
secret = "A"guesses = ["A"]maxGuesses = 0return = falseOnly guesses inside the allowed prefix are considered.
Constraints
1 <= secret.length <= 100.0 <= guesses.length <= 100000.- Every guess has the same length as
secret. 0 <= maxGuesses <= 100000.