Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- check = {")":"(" , "]":"[" , "}":"{" }
- stack = []
- for c in s:
- if c in check.values():
- stack.append(c)
- elif stack and check[c] == stack[-1]:
- stack.pop()
- else:
- return 'NO'
- if stack == []:
- return 'YES'
- else:
- return 'NO'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement