Skip to content

Commit de0fc7e

Browse files
yongjun-0903unknown
andauthored
올바른 괄호 (#69)
Co-authored-by: unknown <Administrator@SKCC20N00129.SKCC.NET>
1 parent 18b26b0 commit de0fc7e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

yongjun-0903/올바른 괄호.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections import deque
2+
3+
def solution(s):
4+
queue = deque([])
5+
6+
for i in s:
7+
if len(queue) == 0:
8+
queue.append(i)
9+
else:
10+
if queue[-1] == '(' and i == ')':
11+
queue.popleft()
12+
else:
13+
queue.append(i)
14+
if len(queue) == 0:
15+
return True
16+
else:
17+
return False
18+

0 commit comments

Comments
 (0)