https://school.programmers.co.kr/learn/courses/30/lessons/76502
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
# 괄호 회전하기
def solution(s):
answer = 0
for _ in range(len(s)):
stack = []
for i in s:
if stack == []:
stack.append(i)
elif stack[-1] == '(' and i==')':
stack.pop()
elif stack[-1] =='[' and i==']':
stack.pop()
elif stack[-1] == '{' and i=='}':
stack.pop()
else:
stack.append(i)
if stack==[]:
answer += 1
s = s[1:] + s[0]
return answer
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[Python] 튜플 (0) | 2022.12.06 |
---|---|
[Python] 포켓몬 (0) | 2022.12.05 |
[Python] 행렬의 곱셈 (0) | 2022.12.02 |
[Python] 캐시 (0) | 2022.11.30 |
[Python] 2016년 (0) | 2022.11.29 |