293. Wildcard matching
Given a string str and a pattern pat, implement a pattern matching function that supports the following special characters:
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
The pattern must match the entire string.
Example 1:
Input: str = "xaylmz", pat = "x?y*z"
Output: true
Explanation:Â
The pattern "x?y*z" matches the string "xaylmz":
- '?' matches 'a'
- '*' matches "lm"
- 'z' matches 'z'
Example 2:
Input: str = "xyza", pat = "x*z"
Output: false
Explanation:Â
The pattern "x*z" does not match the string "xyza" because there is an extra 'a' at the end of the string that is not matched by the pattern.
Now Your Turn!
Pick the correct output for the given inputInput: str = "abc", par = "a?c"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= length of(str, pattern) <= 200