Minimum Money Needed DP


I have used 0-N Knapsack approach
because it is given in question that market has infinite supply of oranges.
Getting wrong answer

I did this using 2D DP also and not getting any output

Hey @dsingh200021, have you checked for the case:
5 5
-1 -1 -1 -1 -1
In this case the output should be -1, but your solution will give 1000.

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.

I also have this doubt… Why have we not used 0-N knapsack approach?