Skip to content

Commit 0de2923

Browse files
committed
Time: 3 ms (31.85%), Space: 19.2 MB (91.01%) - LeetHub
1 parent 744d9e2 commit 0de2923

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ def isValid(self, s: str) -> bool:
66

77
for bracket in s:
88
if bracket in brackets:
9-
# if (bracket is '(') or (bracket is '[') or (bracket is '{'):
109
stack.append(bracket)
1110

1211
else:
1312
if len(stack) is 0:
1413
return False
1514

16-
if brackets[stack[-1]] != bracket:
15+
if brackets[stack.pop()] is not bracket:
1716
return False
18-
stack.pop()
1917
return len(stack) is 0

0 commit comments

Comments
 (0)