Wildcard Matching
Wildcard Matching (LI.192)
Example
isMatch("ab", "?*") => true
isMatch("aa","a") => false
isMatch("aabceef","*a*") => true
isMatch("minutes","m?nu*s") => trueBrute Force Search
Search by prefix
base case
if (i == 0 && j == 0) return true
if either one is not 0 return false
search
if B[j] == '*'
match 1,2,3,4,...
skip
if B[j] == '.'
match 1
if A[i] == B[j]
match 1
else
don't match return falseIncorrect DP
Correct DP
Code
Time & Space Complexity
Last updated