44. Wildcard Matching
problem description
Given an input string (s
) and a pattern (p
), implement wildcard pattern matching with support for '?'
and '*'
.
The matching should cover the entire input string (not partial).
Note:
s
could be empty and contains only lowercase lettersa-z
.p
could be empty and contains only lowercase lettersa-z
, and characters like?
or*
.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
algorithm thought
这题很之前的正则表达式很像,其实还简单一点。使用二维数组保存中间结果,动态规划解决问题。可以借鉴前面动态规划题目的解答。这里的?其实和之前的.一样。这里的*比之前的*更加加单
code
algorithm analysis
时间复杂度O(n²)
Last updated