← Quit0 / 0 correct
What is the recurrence for the classic 0/1 knapsack DP?
dp[i][w] = max(
dp[i-1][w],
dp[i-1][w - wt[i]] + val[i] // if wt[i] <= w
)What is the recurrence for the classic 0/1 knapsack DP?
dp[i][w] = max(
dp[i-1][w],
dp[i-1][w - wt[i]] + val[i] // if wt[i] <= w
)