Back to DSA

Wildcard Matching

hard
Acceptance: 36%
Dynamic Programming

Implement a pattern matcher where '?' stands for any single character and '*' stands for any sequence of characters (including none). The entire input string must be matched by the pattern.

Examples

Example 1:
Input:s = "sequence", p = "s*nce"
Output:true
Explanation: '*' absorbs 'eque', and the remaining characters match literally.
Example 2:
Input:s = "test", p = "te?a"
Output:false
Explanation: '?' matches 's' but 'a' does not match 't'.

Hints

00:00
1234567