File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -4,23 +4,23 @@ package main
4
4
func generateParenthesis (n int ) []string {
5
5
var parentheses []string
6
6
var stack []byte
7
- var backtrack func (int , int )
8
- backtrack = func (open int , closed int ) {
7
+ var generate func (int , int )
8
+ generate = func (open int , closed int ) {
9
9
if open == n && closed == n {
10
10
parentheses = append (parentheses , string (stack ))
11
11
return
12
12
}
13
13
if open < n {
14
14
stack = append (stack , '(' )
15
- backtrack (open + 1 , closed )
15
+ generate (open + 1 , closed )
16
16
stack = stack [:len (stack )- 1 ]
17
17
}
18
18
if open > closed {
19
19
stack = append (stack , ')' )
20
- backtrack (open , closed + 1 )
20
+ generate (open , closed + 1 )
21
21
stack = stack [:len (stack )- 1 ]
22
22
}
23
23
}
24
- backtrack (0 , 0 )
24
+ generate (0 , 0 )
25
25
return parentheses
26
26
}
You can’t perform that action at this time.
0 commit comments