[nb] Commit

This commit is contained in:
2021-08-03 12:42:59 -05:00
parent ff75f25f66
commit db3f97e461
4 changed files with 187 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
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() {
}