문제링크: 괄호 회전하기
✍🏻 Information
| content | |
|---|---|
| 언어 | python |
| 난이도 | ⭐️⭐️ |
| 풀이시간 | 10분 |
| 제출횟수 | 1 |
| 인터넷검색유무 | no |
🍒 My Code
def isright(s):
stack = []
opens,closes = ['[','(','{'],[']',')','}']
for i in s:
if i in opens:
stack.append(i)
else:
if len(stack)==0:
return False
if stack[-1] in opens and opens.index(stack[-1])==closes.index(i):
stack.pop()
return len(stack)==0
def solution(s):
answer = 0
for i in range(len(s)):
_s = s[i:len(s)]+s[:i]
if isright(_s)==True:
answer+=1
return answer
💡 What I learned