Giving WA passes on given test case


Pls check this code and and why it is giving WA but passing the given test case.

hello @Garvit012
first remove all those packet whose value is -1
and then apply 0-1 knapsack.

check this->

if(w < n or a[n-1]==-1)
return op1;

if I add this in the code shouldn’t it work

dont return.
instead skip it.

its a recursion + memorisation approach it has to return something

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.