0 1 Knapsack and 0 N knapsack

0 1 knapsack ques link: https://hack.codingblocks.com/contests/c/512/257
0 N knapsack ques link:https://hack.codingblocks.com/contests/c/512/922

my code link: https://ide.codingblocks.com/s/44604
The doubt is commented in the code.
Please clear the doubt.

Hey Kshitij, the values of dp[i][c] and val[i-1] can be same or different, it will depend on the values of i and c and also on the vals and weights array given in the question. I would suggest you to dry run your code on a paper and make the 2D matrix then it will be clear to you how the matrix is filling and how the values of dp[i][c] and val[i-1] are different but they can be same at some points depending on the values given in the vals and weights arrays.

Thanks a lot for the help