# Leetcode 10 - Regular expression matching

Note:

• DFS witn memo
• DP is too hard so I guess I’ll use DFS instead.
• Base case: when either i or j is bigger than their length, it means we’ve searched all chars in both strs, return true.
• Because of the specialty of *, we have an if-else statement based on whether the next char is * or not.
• If it is, there are two situations: Use it at least once or ignore its preceding char.
• Note: if we are gonna use it, the premise is that (s[i] === p[j] || p[j] === '.').
• If it is not, we just need to check if (s[i] === p[j] || p[j] === '.').
• Some tricky parts:

Question:

Given an input string s and a pattern p, 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:

Code: