Algorithms, Leetcode, Datastrucutre, Java.
the same as for the previous item: dp[i][j] = dp[i-1][j]. Otherwise, we have two choices: Exclude item i: dp[i][j] = dp[i-1][j]. Include item i: dp[i][j] = value[i] + dp[i-1][j — weight[i]]. We choose the maximum of these two options as the value for dp[i][j]. By filling the 2D array in this