Advertisement
Griwin

Untitled

Nov 7th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. check = {")":"(" , "]":"[" , "}":"{" }
  2. stack = []
  3. for c in s:
  4. if c in check.values():
  5. stack.append(c)
  6. elif stack and check[c] == stack[-1]:
  7. stack.pop()
  8. else:
  9. return 'NO'
  10. if stack == []:
  11. return 'YES'
  12. else:
  13. return 'NO'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement