
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Regular Expression Matching
								Certification: Advanced Level
								Accuracy: 0%
								Submissions: 1
								Points: 20
							
							Write a C program to implement regular expression matching with support for '.' and '*'. 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.
Example 1
- Input: s = "aa", p = "a"
- Output: false
- Explanation: Pattern "a" matches only one 'a'. String "aa" has two 'a' characters. Therefore, pattern does not match the string
Example 2
- Input: s = "aa", p = "a*"
- Output: true
- Explanation: Pattern "a*" means zero or more 'a' characters. String "aa" has exactly two 'a' characters. Therefore, pattern matches the string
Constraints
- 1 ≤ s.length ≤ 20
- 1 ≤ p.length ≤ 30
- s contains only lowercase English letters
- p contains only lowercase English letters, '.', and '*'
- It is guaranteed that for each appearance of '*', there will be a previous valid character to match
- Time Complexity: O(m*n) where m and n are lengths of string and pattern
- Space Complexity: O(m*n)
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Use dynamic programming to solve this problem efficiently
- Create a 2D DP table where dp[i][j] represents if s[0...i-1] matches p[0...j-1]
- Handle base cases: empty string and empty pattern
- For '*', consider two cases: match zero characters or match one or more characters
- For '.', it can match any single character
