Complete the code to initialize the dp vector with zeros for the knapsack capacity.
let mut dp = vec![[1]; capacity + 1];
We initialize the dp vector with zeros because initially, the maximum value for any capacity is zero.
Complete the code to iterate over all capacities from 1 to the given capacity.
for w in 1..=[1] {
We iterate from 1 up to the capacity to fill dp for all sub-capacities.
Fix the error in the condition to check if the current item can fit in the knapsack capacity.
if weights[i] [1]= w {
The item fits if its weight is less than or equal to the current capacity.
Fill both blanks to update dp[w] with the maximum value including the current item.
dp[w] = dp[w].[1](dp[w - weights[i]] + [2][i]);
We use max to keep the best value and add the current item's value from values array.
Fill all three blanks to complete the nested loops iterating over items and capacities.
for [1] in 0..[2] { for w in 1..=[3] { // update dp } }
We loop over each item index i from 0 to weights.len() and capacities from 1 to capacity.
