[Programmers] 올바른 괄호
Python
def solution(s):
temp = []
for i in s:
if not temp:
temp.append(i)
elif temp[-1] == '(' and i == ')':
temp.pop()
else:
temp.append(i)
if temp:
return False
else:
return True
댓글남기기