one testcase is not getting passed. Please help me to find the mistake.
The link to the sol is:-
Minimum Money Needed Problem
@krikhi
inside j loop, write if(a[j]==-1){ continue; }. You donβt have to consider those apples whose price is -1 (there are not available).
Change line 23 to if(dp[w]==INT_MAX){ cout<<-1<<endl; }
Thanks for the help. All the testcases are passed.
1 Like