Regular Expression Matching

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*', where '.' matches any single character and '*' matches zero or more of the preceding element. The matching should cover the entire input string.

Constraints

  • 1 <= s.length <= 20
  • 1 <= p.length <= 20
  • s contains only lowercase English letters.
  • p contains only lowercase English letters, '.', and '*'.
  • Each '*' in the pattern has a previous valid character to match.
Saving… · 2 lines
class Solution:
def regular_expression_matching(self, s: str, p: str) -> bool:
Console

Click Run to execute sample tests.