Complete the code to initialize the DP table with zeros.
let mut dp = vec![vec![[1]; capacity + 1]; n + 1];
The DP table must be initialized with zeros to represent no items or zero capacity.
Complete the code to check if the current item's weight fits in the current capacity.
if weights[i - 1] [1] w {
We check if the item's weight is less than or equal to the current capacity to decide if we can include it.
Fix the error in the code to correctly update the DP table when including the item.
dp[i][w] = dp[i - 1][w - weights[i - 1]] [1] values[i - 1];
We add the current item's value to the best value without this item's weight.
Fill both blanks to choose the maximum value between including and excluding the item.
dp[i][w] = std::cmp::[1](dp[i - 1][w], dp[i - 1][w - weights[i - 1]] [2] values[i - 1]);
We take the maximum of excluding or including the item (which adds its value).
Fill all three blanks to complete the nested loops iterating over items and capacities.
for [1] in 1..=[2] { for [3] in 0..=capacity {
The outer loop runs over items (i from 1 to n), the inner loop over capacities (w from 0 to capacity).
