Skip to content

Commit 67e48af

Browse files
authored
[BOJ] 4949 균형잡힌 세상 (S4)
1 parent 8d5796c commit 67e48af

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

김지호/7주차/260211.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
while True :
3+
a = input()
4+
stack = []
5+
6+
if a == "." :
7+
break
8+
9+
for i in a :
10+
if i == '[' or i == '(' :
11+
stack.append(i)
12+
elif i == ']' :
13+
if len(stack) != 0 and stack[-1] == '[' :
14+
stack.pop() # 맞으면 지워서 stack을 비워줌 0 = yes
15+
else :
16+
stack.append(']')
17+
break
18+
elif i == ')' :
19+
if len(stack) != 0 and stack[-1] == '(' :
20+
stack.pop()
21+
else :
22+
stack.append(')')
23+
break
24+
if len(stack) == 0 :
25+
print('yes')
26+
else :
27+
print('no')

0 commit comments

Comments
 (0)