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