Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(n):
- def solve(left, right, x):
- if left == right and right == n:
- print x
- return
- if left < n:
- solve(left + 1, right, x + '(')
- if right < left:
- solve(left, right + 1, x + ')')
- solve(0, 0, '')
- import sys
- solve(int(sys.argv[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement