I tried a lot debugging the code but Im getting WA for two test cases. Can anyone pls look at my code and suggest changes.
Code
I tried a lot debugging the code but Im getting WA for two test cases. Can anyone pls look at my code and suggest changes.
Code
Im getting the same test cases wrong in both top down and bottom up code
It will be helpful if any of the TAβs reply back
the problem is you messed up with n and N.
//bottom up
dp[0]=0;
dp[1]=cnt[1];
for(int i=2;i<=n;++i)
{
dp[i] = max(dp[i-1],cnt[i]*i+dp[i-2]);
}
cout<<dp[n]<<"\n";
use N instead of n in this part of code.
thanks
rate and resolve if satisfied.