LC010 - Regular Expression Matching
Last updated
Last updated
Given an input string s
and a pattern p
, implement regular expression matching with support for '.'
and '*'
where:
'.'
Matches any single character.āāāā
'*'
Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
Input: s = "aa", p = "a"
Output: false
Explanation: "a" does not match the entire string "aa".
The naive approach to traverse the entire parsing decision tree is in time complexity.
With a cache, we can get it down to , at the cost of extra space.