Hard

Quiz

#44 Wildcard Matching

APPROACH

Implement wildcard pattern matching for string s against pattern p, where '?' matches any single character and '*' matches any sequence of zero or more characters. The entire input string must be covered.

Example 1:

Input: s = "aa", p = "a"
Output: false
Explanation: "a" does not match the entire string "aa".

Example 2:

Input: s = "aa", p = "*"
Output: true
Explanation: '*' matches any sequence.

Example 3:

Input: s = "cb", p = "?a"
Output: false
Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.
1 of 4
1:00

What is the optimal approach for this problem?