I am unable to point out the bug in my below code for this problem. Please help. I used the same formula that was given in the video solution and my base cases also are correct

#include
using namespace std;
long long int DP[20] = {0};

long long int count( int S[], int m, int n ){
if(DP[n])
return DP[n];
if(S[m-1] > n)
return 0;
if(n < 0)
return 0;
if(m<=0)
return 0;

    return DP[n] = count(S, m-1, n) + count(S, m, n - S[m-1]);

}

int main(){
int n, m;
cin>>n>>m;
int S[m];
DP[0] = 1;
for(int i=0; i<m; i++)
cin>>S[i];
cout<<count(S, m, n);
return 0;
}

hello @vsinghal202

pls save ur code at cb ide and share its link with me

I have submitted my code, you can check in the submission section - check for latest submission submitted at the time of writing this comment

go to this link -> https://ide.codingblocks.com/

paste ur latest code in the editor , press ctrl + s and then save

a url will be generated in ur search bar, copy that url and paste it here

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.