Here’s the link to my code
My code passes on 2 test cases and shows the wrong answer on first test case.
In the given problem, it says that we have infinite supply of oranges so should we consider this problem as a 01Knapsack problem or an Unbounded Knapsack problem.
In the hint video the approach mentioned is 01Knapsack but I believe the problem should be treated as NKnapsack problem.
Minimum Money Needed
1 Like
Hi isa67719
It should be unbounded knapsack as we have all weights available at all times. Refer to this : https://www.geeksforgeeks.org/unbounded-knapsack-repetition-items-allowed/
Correct code : https://ide.codingblocks.com/s/152494
Hope it helps
Mark resolved if satisfied
1 Like