Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Brackets by arek.kowalski107
def checkio(expr):
stack = []
for c in expr:
if c in set(["{", "[", "("]):
stack.append(c)
if c == "}":
if len(stack) <= 0 or stack[-1] != "{":
return False
stack.pop()
if c == "]":
if len(stack) <= 0 or stack[-1] != "[":
return False
stack.pop()
if c == ")":
if len(stack) <= 0 or stack[-1] != "(":
return False
stack.pop()
if len(stack) > 0:
return False
return True
Dec. 14, 2016