Problem
Ask
Submissions

Problem: Regular Expression Matching

Medium
30 min
Explore how to solve the regular expression matching problem using dynamic programming. Understand how '.' matches any character and '*' matches zero or more of the preceding character. This lesson helps you implement an efficient algorithm to cover the entire input string using these regex patterns.

Statement

You are given an input string, s, and a pattern string, p. Your task is to implement regular expression matching between s and p, where the pattern may include the special characters '.' and '*':

  • '.' matches any single character.

  • '*' matches zero or more occurrences of the preceding character.

The match must cover the entire input string, not just part of it.

Constraints:

  • 11 \leq s.length 20\leq 20

  • 11 \leq p.length 20\leq 20

  • s contains only lowercase English letters.

  • p contains only lowercase English letters, '.', and '*'.

  • It is guaranteed that for each appearance of the character '*', there will be a previous valid character to match.

Problem
Ask
Submissions

Problem: Regular Expression Matching

Medium
30 min
Explore how to solve the regular expression matching problem using dynamic programming. Understand how '.' matches any character and '*' matches zero or more of the preceding character. This lesson helps you implement an efficient algorithm to cover the entire input string using these regex patterns.

Statement

You are given an input string, s, and a pattern string, p. Your task is to implement regular expression matching between s and p, where the pattern may include the special characters '.' and '*':

  • '.' matches any single character.

  • '*' matches zero or more occurrences of the preceding character.

The match must cover the entire input string, not just part of it.

Constraints:

  • 11 \leq s.length 20\leq 20

  • 11 \leq p.length 20\leq 20

  • s contains only lowercase English letters.

  • p contains only lowercase English letters, '.', and '*'.

  • It is guaranteed that for each appearance of the character '*', there will be a previous valid character to match.