Skip to content

Instantly share code, notes, and snippets.

@decagondev
Created April 23, 2025 21:17
Show Gist options
  • Save decagondev/5b7f6e2c3fbba449cc713aab603433e7 to your computer and use it in GitHub Desktop.
Save decagondev/5b7f6e2c3fbba449cc713aab603433e7 to your computer and use it in GitHub Desktop.

PROBLEM 9: Regular Expression Matching

Problem Statement

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*':

  • '.' Matches any single character.
  • '*' Matches zero or more of the preceding element.

The matching should cover the entire input string (not partial).

Concepts Covered

  • Dynamic Programming
  • Recursive Backtracking
  • Pattern Matching

Examples

Input: s = "aa", p = "a"
Output: False

Input: s = "aa", p = "a*"
Output: True

Input: s = "mississippi", p = "mis*is*p*."
Output: False

Starter Code

def is_match(s: str, p: str) -> bool:
    # Implement your solution here
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment