Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
stack solution in Clear category for Brackets by juestr
brackets = dict(zip('({[', ')}]'))
def checkio(expression):
stack = []
for b in expression:
if b in brackets:
stack.append(b)
elif stack and b == brackets[stack[-1]]:
stack.pop()
elif b in brackets.values():
return False
return not stack
Dec. 15, 2022