Code might fail for larger test cases.What is the problem in this code? Please help


#1

Comment body goes int look[1000][1000];
long long int mod=1000000007;
long long int func(int n,int s)
{
if(s==0){return 1;}
if(n==1 && s<=9) {look[n-1][s-1]=1;}
else if(look[n-1][s-1]==-1)
{
int ans=0;
for(int i=0;i<=9;i++)
{
if(s-i>=0){ans=(ans+func(n-1,s-i)%mod)%mod;}
}
look[n-1][s-1]=ans%mod;
}
return look[n-1][s-1];
}
int Solution::solve(int A, int B)
{
if(A==0||B==0)return 0;
for(int i=0;i<1000;i++){for(int j=0;j<1000;j++){look[i][j]=-1;}}
long long int ans =0;
for(int i=1;i<=9;i++)
{
if(B-i>=0){ans=(ans+func(A-1,B-i)%mod)%mod;}
}
int res=(int)(ans%mod);
//for(int i=0;i<A;i++){for(int j=0;j<B;j++){cout<<look[i][j]<<" ";}cout<<endl;}
return res;
}here.