https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem/0
Does not get correct output in knapsack geeksforgeeks. what is the problem in this code
@rohitkandpal683
Your code had multiple mistakes.
- you are doing it with 1D dp array, but this is not how you solve knapsack with 1D.
- The knapsack was not 0-1 knapsack, because at each step you were iterating form 0 to n-1.
- W-weight[i]>0 this can be equal to zero as well.
I have corrected the code, but still, I think you have skipped some lectures from the course, or you have not revised them. I strongly suggest you go through them once again before moving onto any other platform.