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 c51b8bd commit fcfd652Copy full SHA for fcfd652
valid-parentheses/sejineer.py
@@ -0,0 +1,21 @@
1
+"""
2
+시간 복잡도: O(N)
3
+공간 복잡도: O(N)
4
5
+class Solution:
6
+ def isValid(self, s: str) -> bool:
7
+ pair = {'(': ')', '{': '}', '[': ']'}
8
+ stack = []
9
+ for c in s:
10
+ if c in ('(', '{', '['):
11
+ stack.append(c)
12
+ else:
13
+ if stack:
14
+ cur = stack.pop()
15
+ if pair[cur] == c:
16
+ continue
17
18
+ return False
19
20
21
+ return not stack
0 commit comments