10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b4e5e29 commit 85bc9a9Copy full SHA for 85bc9a9
RegularExpressionMatching.h
@@ -49,12 +49,12 @@ class Solution {
49
50
bool isMatch_2(const char *s, const char *p) {
51
if (*p == '\0') return *s == '\0';
52
-
53
- if (*s == *p || *p == '.' && *s != '\0')
54
- return *(p+1) != '*' ? isMatch(s+1, p+1) :
55
- isMatch(s+1, p) || isMatch(s, p+2);
56
- else
57
- return *(p+1) == '*' && isMatch(s, p+2);
+ if ((*s != '\0') && (*s == *p || *p =='.')) {
+ if (*(p+1) == '*') {
+ return isMatch(s+1,p) || isMatch(s, p+2);
+ } else return isMatch(s+1, p+1);
+ }
+ return *(p+1) == '*' && isMatch(s, p+2);
58
}
59
60
bool isMatch_3(const char *s, const char *p) {
0 commit comments