i have approached this problem using 2D dp but i am getting wrong answer. please check my code and guide
Minimum money needed
minor mistake, easy to miss, took me a long time to figure out as well, in ur code, your input is wrong, look at this correct submitted code, ur taking n and w as interchanged