
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Regular Expression Matching
								Certification: Advanced Level
								Accuracy: 0%
								Submissions: 0
								Points: 15
							
							Write a C++ program to implement regular expression matching with support for '.' and '*' where:
- '.' Matches any single character.
- '*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
Example 1
- Input: s = "aa", p = "a*"
- Output: true
- Explanation: - '*' means zero or more of the preceding element, 'a'.
- Therefore, by repeating 'a' once, it becomes "aa".
 
Example 2
- Input: s = "mississippi", p = "mis*is*p*."
- Output: false
- Explanation: - The pattern doesn't match the entire string because the final '.' needs to match the last 'i' in "mississippi".
- But there's still a 'p' and 'i' left unmatched.
 
Constraints
- 1 ≤ s.length ≤ 20
- 1 ≤ p.length ≤ 30
- s contains only lowercase English letters
- p contains only lowercase English letters, '.', and '*'
- 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
- Create a 2D DP table where dp[i][j] represents if s[0...i-1] matches p[0...j-1]
- Handle the special case of '*' which can match zero or more of the preceding character
- Initialize the base cases carefully, especially for empty strings
- Consider all possible pattern combinations when '*' is involved
