Sample test cases are passing.
ALL test Cases are Failing
Hey Ambuj! As i can see there are few mistakes in your code. firstly, weights array doesn’t represent the weight of ith orange, it represents the price if ith orange. Weight of ith orange is "i"kg. So change line no. 22 to “if(w-i>=0 and weights[i]!=-1)” .
And also there is mistake in line no. 24, call Helper(w-i, weights, dp), not w-1.
Make these changes and your code will work fine
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.