Skip to content

Commit 36e1692

Browse files
committed
Time: 0 ms (100%), Space: 19.1 MB (91.01%) - LeetHub
1 parent 68a05da commit 36e1692

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎LeetCode/Easy/0020-valid-parentheses/0020-valid-parentheses.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ def isValid(self, s: str) -> bool:
99
stack.append(bracket)
1010

1111
else:
12-
if len(stack) is 0:
13-
return False
12+
# if len(stack) is 0:
13+
# return False
1414

15-
if brackets[stack.pop()] is not bracket:
15+
# if brackets[stack.pop()] is not bracket:
16+
# return False
17+
18+
if not stack or bracket != brackets[stack.pop()]:
1619
return False
17-
return len(stack) is 0
20+
return not stack

0 commit comments

Comments
 (0)