//不同的二叉搜索树
package leetcode;
public class App {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=makeTree(3);
System.out.println(n);
}
public static int makeTree(int n)
{
int G[]=new int[n+1];
G[0]=1;
G[1]=1;
for(int i=2;i<=n;i++)
{
//G[i]=0;
for(int j=1;j<=i;j++)
{
G[i]+=G[j-1]*G[i-j];//卡特兰数
}
}
return G[n];
}
}
不同的二叉搜索树---卡特兰数
最新推荐文章于 2021-11-15 09:40:39 发布