Wildcard Matching
HardP3Coding
Implement wildcard matching of the whole string s against the pattern p, where p may contain:
?which matches any single character,*which matches any sequence of characters, including the empty sequence.
Return true only if the pattern covers the entire string.
Example 1
- Input
- s = "aa", p = "a"
- Output
- false
- Why
- A single `a` cannot cover two characters.
Example 2
- Input
- s = "aa", p = "*"
- Output
- true
- Why
- `*` matches any string.
Example 3
- Input
- s = "cb", p = "?a"
- Output
- false
Constraints
- 0 <= s.length, p.length <= 1000
scontains lowercase letters;pcontains lowercase letters,?and*
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 13. ⌘Enter runs, ⌘⇧Enter submits.