You are viewing a single comment's thread. Return to all comments →
Python3 equivalent:
def is_matched(expression): stack = [] dicty = {'(':')', '[':']', '{':'}'} for x in expression: if dicty.get(x): stack.append(dicty[x]) else: if len(stack) == 0 or x != stack[len(stack)-1]: return False stack.pop() return len(stack) == 0
Seems like cookies are disabled on this browser, please enable them to open this website
Stacks: Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
Python3 equivalent: