# leetcode22.括号的生成

```golang
var res []string
var stack string
func generateParenthesis(n int) []string {
    res=make([]string,0)
    back(n,n)
    return res
}

func back(left,right int){
    if left>right{
        return
    }

    if left<0 ||right<0{
        return
    }
    if left==0 &&right ==0{
        res=append(res,stack)
    }

    stack+="("
    back(left-1,right)
    stack=stack[:len(stack)-1]

    stack+=")"
    back(left,right-1)
    stack=stack[:len(stack)-1]
}
```
