Merge pull request #142 from QuinnDK/添加0096不同的二叉搜索树Go版本
添加0096不同的二叉搜索树Go版本
This commit is contained in:
commit
25958826de
|
|
@ -189,7 +189,18 @@ Python:
|
||||||
|
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
```Go
|
||||||
|
func numTrees(n int)int{
|
||||||
|
dp:=make([]int,n+1)
|
||||||
|
dp[0]=1
|
||||||
|
for i:=1;i<=n;i++{
|
||||||
|
for j:=1;j<=i;j++{
|
||||||
|
dp[i]+=dp[j-1]*dp[i-j]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dp[n]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue