Skip to content

Commit

Permalink
2024-03-11 쇠막대기
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon030 committed Mar 11, 2024
1 parent faecaf6 commit 7c6cbda
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions seongwon030/스택/쇠막대기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
s = input()

stack = []
cnt = 0

for i in range(len(s)):
if s[i] == '(':
stack.append('(')
else:
if s[i-1] == ')':
stack.pop()
cnt+=1
else:
stack.pop()
cnt += len(stack)
print(cnt)

0 comments on commit 7c6cbda

Please sign in to comment.