0-n knapsack problem


this code is not passing all testcases …plz correct

@S19LPPP0202
you have to use long long, and initialise the dp array as -1

why cant we initialize it with zero??

you can initialise it with zero as well.
just a precautionary measure try to initialize it with -1.
in this case, initializing it with zero will give correct result.

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.