My 0-1 knapsack code works when I initialize my DP array with 0 but doesn't work when I initialize it with -1

What is the reason behind this??

My solution:

hello @anshufirefox

check now-

u were not intilalising correctly

Thanks a lot :slight_smile:

Apart from the solution, I really appreciate the quick response. Thank you again.

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.