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 bd7583d commit b45e7f6Copy full SHA for b45e7f6
valid-parentheses/jongwanra.py
@@ -12,8 +12,6 @@
12
Time: O(N), N = s.length
13
Space: O(N), N = stack.length
14
"""
15
-from os import popen
16
-
17
18
class Solution:
19
def isValid(self, s: str) -> bool:
@@ -23,11 +21,12 @@ def isValid(self, s: str) -> bool:
23
21
# 여는 괄호인 경우 Stack 추가
24
22
if bracket in bracket_dict:
25
stack.append(bracket)
26
- continue
27
28
# 닫는 괄호인 경우
29
- if not stack or bracket_dict[stack.pop()] != bracket:
30
- return False
+ else:
+ if not stack:
+ return False
+ if bracket_dict[stack.pop()] != bracket:
31
32
return not stack
33
@@ -44,3 +43,4 @@ def isValid(self, s: str) -> bool:
44
43
print(sol.isValid("(") == False)
45
print(sol.isValid("]") == False)
46
+
0 commit comments