algorythms
Dynamic Programming
LC #10Hard

Regular Expression Matching

Dynamic Programming
MetaGoogleBloomberg

Problem

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

Inputs = "aa", p = "a*"
Outputtrue
Why

"a*" means zero or more "a"s, which matches "aa"

Hints — reveal one at a time