Wildcard Matching - Problem
Given an input string s and a pattern p, implement wildcard pattern matching with support for '?' and '*':
'?'matches any single character'*'matches any sequence of characters (including the empty sequence)
The matching should cover the entire input string (not partial).
Input & Output
Example 1 — Basic Wildcard Matching
$
Input:
s = "adceb", p = "*a*b*"
›
Output:
true
💡 Note:
The first '*' matches "ad", 'a' matches 'a', the second '*' matches "ce", 'b' matches 'b', and the last '*' matches the empty string.
Example 2 — No Match
$
Input:
s = "adceb", p = "*a*b"
›
Output:
false
💡 Note:
Pattern ends with 'b' but string ends with 'b'. However, the pattern requires exact match of entire string, and there are extra characters after matching.
Example 3 — Question Mark Wildcard
$
Input:
s = "cb", p = "?a"
›
Output:
false
💡 Note:
'?' matches 'c', but 'a' doesn't match 'b', so the pattern fails.
Constraints
- 0 ≤ s.length, p.length ≤ 2000
- s contains only lowercase English letters
- p contains only lowercase English letters, '?' or '*'
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code