cheetcode

121. Regular Expression MatchingHard

Implement matching for patterns that include dot and star wildcards.

Given strings s and p, return true if p matches the entire string s.

A dot matches any single character. An asterisk means zero or more of the preceding element.

Examples

Input: s = "aa", p = "a*"
Output: true
Input: s = "ab", p = ".*"
Output: true

Constraints

  • 1 <= s.length <= 20
  • 1 <= p.length <= 30
  • s contains only lowercase English letters.
  • p contains lowercase English letters, '.' and '*'.