Minimum cost to fill given weight in a bag

I know IT is a DP problem but my recursive solution is giving wrong answer on small test cases only so help me to correct my recursive solution so that I can MEMOIZE IT

just help me to correct the recursive code will be very thankful
problem https://practice.geeksforgeeks.org/problems/minimum-cost-to-fill-given-weight-in-a-bag1956/1#
my code
https://ide.codingblocks.com/s/579568

@joshisanjay8467 it is due to the overflow error use long long as the return type of the function and also in a call when i+1<=wt
i have change the code a little bit now you can memorize it
Coding Blocks IDE
please ask further if the issue is not solved and if solved please mark it as solved and rate experience

1 Like

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.