Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string
- helper(n,0,0,"", &res)
- return res
- }
- func helper (n int, open int, close int, currentStr string, res *[]string) {
- if open == n && close == n {
- *res = append(*res,currentStr)
- return
- }
- if open < n {
- helper(n, open + 1, close, currentStr + "(", res)
- }
- if open > close {
- helper(n,open, close + 1, currentStr+ ")", res)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement