C 0ms DP sulotion


  • 0
    H

    int numTrees(int n) {

    if(n==0)
        return 0;
    int R[n+1];
    R[0] = 0;
    R[1] = 1;
    int i,j;
    for(i = 2; i <= n; i++)
    {
    	R[i]=2*R[i-1];
    	for(j = 2; j < i; j++)
            R[i]+=R[j-1]*R[i-j];
    }
    return R[n];
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.