Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using stack solution in Clear category for Brackets by quarkov
#This should work faster than .replace method
def checkio(line):
op = ['(', '[', '{']
cl = [')', ']', '}']
stack = []
for i in line:
if i in op:
stack.append(i)
elif i in cl:
if not stack or cl.index(i) != op.index(stack.pop()):
return False
return not stack
May 11, 2018