I have done this using recursion so it gives TLE for first case but for second and third testcase it gives wrong answer. May I know what are those testcases? Later I will optimize it using DP. Here is the code:
Minimum Money Needed
but then n=6 and then my code gives correct answer
ok i got it that there are W elements in array but whats the use of N?
try for this input
5 10
-1 33 -1 176 -1 46 -1 120 -1 300
correct output : 112