Problem
Return whether the pattern mask matches the whole string text under these wildcard rules:
-
A lowercase letter in
mask
matches the same letter in
text
.
-
?
matches exactly one character.
-
*
matches a sequence of any length, including zero characters.
Every pattern character participates in the match, and the match must consume all of text. Finding a matching portion of the text is insufficient.
Examples
Example 1
Input: text = "cabin", mask = "c*?n"
Output: true
The star can cover "ab", the question mark covers "i", and the literal letters match the ends of the text.
Example 2
Input: text = "", mask = "*?"
Output: false
The star may cover no characters, but the question mark still needs one character, which the empty text cannot supply.
Constraints
-
0 <= text.length <= 2000
-
0 <= mask.length <= 2000
-
The text contains lowercase English letters only.
-
The mask contains lowercase English letters,
?
, and
*
only.