Guru Level
Implement the method isWildcardMatch that checks whether a string matches a wildcard pattern.
The pattern supports ? for exactly one character and * for any sequence of characters, including empty.
The task is designed to test careful handling of edge cases, not only the most common input.
- The entire string must match the entire pattern.
- Normal letters must match exactly.
*can either match nothing or consume one more character.
Example 1
Input
s (string) =
aap (string) =
aReturns (boolean)
falseExample 2
Input
s (string) =
aap (string) =
*Returns (boolean)
trueExample 3
Input
s (string) =
cbp (string) =
?aReturns (boolean)
falseExample 4
Input
s (string) =
adcebp (string) =
*a*bReturns (boolean)
trueUse dynamic programming where dp[i][j] means the first i characters of the string match the first j characters of the pattern.
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run