Determine whether a pattern containing ? and * can match an entire input string.
You are given two strings:
s: the input textp: a pattern that may contain ordinary lowercase characters plus two wildcard symbols:
? matches exactly one character* matches any sequence of characters, including the empty sequenceReturn whether the entire string s can be matched by the entire pattern p.
A match must consume all characters in both strings. Partial matches do not count.
spBoth strings are composed of lowercase letters and the pattern may additionally contain ? and *.
true if p matches all of sfalse? matches exactly one character* matches zero or more charactersExample 1
Input
s = "adceb", p = "*a*b"
Output
true
Explanation
* can match the empty prefix, then a matches a, the second * matches dce, and b matches b.
Example 2
Input
s = "acdcb", p = "a*c?b"
Output
false
Explanation
No assignment of characters to the wildcards allows the pattern to consume the entire string while preserving the fixed letters.
Example 3
Input
s = "", p = "*"
Output
true
Explanation
* can match the empty sequence.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.