from collections import deque #deque 선언
def solution(s):
answer = True
check = 0
stack = deque(s) # input을 deque화 하기
while(stack):
bracket = stack.popleft()
if bracket == "(" :
check = check + 1
else :
check = check - 1
if check < 0 :
answer = False
break
if check > 0 :
answer = False
return answer
[python]dict? 해시? (0) | 2023.03.30 |
---|---|
[python]짝지어 제거하기, stack (0) | 2023.03.28 |
[python]숫자로 이루어진 문자열을 int형 list로 변경 (0) | 2023.03.25 |
ImportError: cannot import name 'BeautifulSoup' (0) | 2023.03.06 |
xcrun: error: invalid active developer path (0) | 2023.02.09 |
댓글 영역