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 1c3a16b commit f423e88Copy full SHA for f423e88
valid-parentheses/daiyongg-kim.py
@@ -0,0 +1,22 @@
1
+class Solution:
2
+ def isValid(self, s: str) -> bool:
3
+ stack = []
4
+
5
+ for c in s:
6
+ if c == '(' or c == '[' or c == '{':
7
+ stack.append(c)
8
+ else:
9
+ if not stack:
10
+ return False
11
12
+ cur = stack.pop()
13
+ if cur == '(' and c != ')':
14
15
+ if cur == '{' and c != '}':
16
17
+ if cur == '[' and c != ']':
18
19
20
+ return True
21
22
0 commit comments