10000 update · leetcoders/LeetCode@85bc9a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85bc9a9

Browse files
author
applewjg
committed
update
Change-Id: Ib1d3fcd3b896090a2ebb8f5631c7cefdf5d2c767
1 parent b4e5e29 commit 85bc9a9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

RegularExpressionMatching.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class Solution {
4949

5050
bool isMatch_2(const char *s, const char *p) {
5151
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);
52+
if ((*s != '\0') && (*s == *p || *p =='.')) {
53+
if (*(p+1) == '*') {
54+
return isMatch(s+1,p) || isMatch(s, p+2);
55+
} else return isMatch(s+1, p+1);
56+
}
57+
return *(p+1) == '*' && isMatch(s, p+2);
5858
}
5959

6060
bool isMatch_3(const char *s, const char *p) {

0 commit comments

Comments
 (0)
0