Wildcard Matching
Problem
Match string s against pattern p containing ? (matches any single character) and * (matches any sequence, including empty). The match must cover the ENTIRE string. Pin the exact semantics first, as variants exist.
Input / Output
- Input: strings
sandp. - Output: boolean — whether
pfully matchess.
Constraints
- Lengths up to 2000; O(mn) DP accepted; a greedy two-pointer runs O(m+n) average.
Example
- s =
"adceb", p ="*a*b"→ true. - s =
"acdcb", p ="a*c?b"→ false. - s =
"aa", p ="*"→ true.
asked …