Class assignment

please tell me the problem in this code

Hello @gauravmadan583,

Logically your code is correct. You have identified the correct logic.
Then, why is not passing the testcase?

Reason:
Your output format doesn’t match with that of the question.

Solution:
You are not required to print the value of n after #
Rather you have to print the number of iterations till that particular instance.

Modification:
cout<<"#"<<i+1<<" : "<<dp[n]<<endl;

Give a like, if you are satisfied.