Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = input()
- Check = []
- res = 'YES'
- for i in A:
- if (i == '[' or i == '(' or i == '{'):
- Check.append(i)
- elif i == ']' and len(Check) > 0 and Check[-1] == '[':
- Check.pop()
- elif i == ')' and len(Check) > 0 and Check[-1] == '(':
- Check.pop()
- elif i == '}' and len(Check) > 0 and Check[-1] == '{':
- Check.pop()
- else:
- res = 'NO'
- break
- if len(Check) != 0:
- res = 'NO'
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement