【leetcode】96. 不同的二叉搜索树

 

int numTrees(int n){
    int hash[50]={0} ,i, j;
    hash[0]=1;
    for(i=1; i<=n; i++)
        for(j=1; j<=i; j++)
            hash[i] += hash[j-1]*hash[i-j];
    return hash[n];
}

 

posted @ 2020-12-15 12:16  温暖了寂寞  阅读(56)  评论(0编辑  收藏  举报