/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcgenerateTrees(nint)[]*TreeNode{vardfsfunc(l,rint)[]*TreeNodedfs=func(l,rint)[]*TreeNode{ifl>r{return[]*TreeNode{nil}}varret[]*TreeNodefori:=l;i<=r;i++{left,right:=dfs(l,i-1),dfs(i+1,r)forj:=0;j<len(left);j++{fork:=0;k<len(right);k++{ret=append(ret,&TreeNode{Val:i,Left:left[j],Right:right[k]})}}}returnret}returndfs(1,n)}