Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = "((([]){}))"
- stack = []
- good = True
- for c in s:
- if c in '[{(':
- stack.append(c)
- elif c in ')}]':
- if not stack:
- good = False
- break
- opening = stack.pop()
- if opening + c not in ['()', '[]', '{}']:
- good = False
- break
- if stack:
- good = False
- print(s, 'is', good)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement