LeetCode/dynamic-programming/22-generate-parenthesis/golang/main.go

57 lines
849 B
Go

package main
/*
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Example 1:
Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
Example 2:
()()(); (())(); ((()));
()(());
(()())
Input: n = 1
Output: ["()"]
()(); (())
Constraints:
1 <= n <= 8
*/
func rec(int index, dp map[string]string) {
}
func generateParenthesis(n int)[] string {
if n == 1 {
return []string{"()"}
}
if n == 2 {
return []string{"()()", "(())"}
}
var output = make([]string, 0)
var dp = map[string]string{}
var start_string string = ""
for i := 0; i < n - 1; i++ {
start_string = start_string + "()"
out_arr = a
}
output = append(output, start_string)
for i := 1; i < n - 1; i++ {
result := rec(i+1, dp) + rec(i-1)
}
}
func main() {
}