Can anyone please help me?Whats wrong in this code?I am getting a different ans for n>21


#1

#define MOD 1000000007
vector dp;

int func(int n)
{
if(!dp[n])
{
int x=0;
int y=n-2;

long long int sum=0;
while(x<=n-2)
{
dp[n]+=(func(x)*func(y))%MOD;
dp[n]=dp[n]%MOD;
x+=2;
y-=2;
}

  }
return dp[n];

}
int Solution::chordCnt(int n) {

dp.resize(3000);

dp[0]=1;
dp[2]=1;
dp[4]=2;

return func(2*n);
}


#2

Here func(x) and func(y) are of type int. But multiplying them can be bigger than int.
So, instead do this: ((long long int) func(x)) * ((long long int) func(y))