Wildcard Matching
Given an input string s and a pattern p, return true if p matches the entire string s. The pattern supports '?', which matches any single character, and '*', which matches any sequence of characters including the empty sequence. The match must cover all of s.
Open official problem prompt ↗We want to know whether the glob pattern can be stretched over the entire string, treating '*' as any run and '?' as one character.
Exactly like matching a shell wildcard such as *a*b against a filename: '*' can swallow any stretch of characters.
- Input
- s = "adceb", p = "*a*b"
- Output
- true
- Why
- The first '*' matches the empty string, 'a' matches 'a', the second '*' matches "dce", and 'b' matches 'b'.
0 <= s.length, p.length <= 2000s contains only lowercase English lettersp contains lowercase letters, '?', and '*'