Skip to content

Commit ff1efcc

Browse files
committed
Update wildcard-matching.py
1 parent 4c426b4 commit ff1efcc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Python/wildcard-matching.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ def isMatch(self, s, p):
9898
class Solution4:
9999
# @return a boolean
100100
def isMatch(self, s, p):
101-
if len(p) == 0:
102-
return len(s) == 0
101+
if not p:
102+
return not s
103103

104104
if p[0] != '*':
105-
if len(s) == 0 or (p[0] == s[0] or p[0] == '?'):
105+
if not s or (p[0] == s[0] or p[0] == '?'):
106106
return self.isMatch(s[1:], p[1:])
107107
else:
108108
return False

0 commit comments

Comments
 (0)