Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # you can write to stdout for debugging purposes, e.g.
- # print("this is a debug message")
- def solution(S):
- # write your code in Python 3.6
- d = {"(":")","[":"]","{":"}"}
- stack = []
- for s in S:
- if s in d:
- stack.append(s)
- else:
- if stack == [] or d[stack.pop()] != s:
- return 0
- if stack != []:
- return 0
- return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement