😎코딩테스트 연습>월간 코드 챌린지 시즌2>괄호 회전하기
def solution(s):
answer = 0
dict = { ")": "(", "}": "{", "]":"["}
for i in range(len(s)):
stack = []
s = s[1::]+s[0]
for x in s:
if (x in '({['):
stack.append(x)
else:
if (stack):
top = stack.pop()
if dict[x] != top:
stack.append(top)
break
else:
stack.append("1")
break
if len(stack) == 0:
answer += 1
return answer