Dynamic Programming
LC #10Hard
Regular Expression Matching
Dynamic Programming
MetaGoogleBloombergProblem
Implement regex matching with '.' (matches any single character) and '*' (matches zero or more of the preceding element).
stringdynamic-programmingrecursion
Constraints
- ›1 ≤ s.length ≤ 20
- ›1 ≤ p.length ≤ 30
- ›s contains only lowercase letters
- ›p contains lowercase letters, ".", and "*"
Example
Input
s = "aa", p = "a*"Output
trueWhy
"a*" means zero or more "a"s, which matches "aa"