Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = input()
- st = []
- for e in s:
- if e in '{[(':
- st.append(e)
- else:
- if len(st) == 0:
- print('NO')
- exit(0)
- if st[-1] + e in ['[]', '{}', '()']:
- st.pop(-1)
- else:
- print('NO')
- exit(0)
- if len(st) == 0:
- print('YES')
- else:
- print('NO')
Advertisement
Add Comment
Please, Sign In to add comment