What is the problem with this code Please help


#1

×
int Solution::numTrees(int A) {
vector dp(A,0);
dp[0]=1;
dp[1]=1;
dp[2]=2;
for(int i=3;i<=A;i++)
{
for(int j=0;j<=i;j++)
{
dp[i]+=(dp[j]*dp[i-j-1]);
}
}
return dp[A];
}


#2

It is showing runtime error


#3

In the second “for” loop, remove " = "
it’ll be for(int j=0;j<i;j++), as in dp[j[, you’ll be getting dp[i] because of equality which you don’t know yet