Wildcard Matching
Solution Code
class Solution:def isMatch(self, s: str, p: str) -> bool:i, j = 0, 0match, star = 0, -1while i < len(s):
if j < len(p) and (s[i] == p[j] or p[j] == '?'):
i += 1
j += 1
elif j < len(p) and p[j] == '*':
star = j
match = i
j += 1
elif star != -1:
j = star + 1
match += 1
i = match
else:
return False
while j < len(p) and p[j] == '*':
j += 1
return j == len(p)Time Complexity
O(S * P)
Space Complexity
O(1)

