Analyze the solve unbounded knapsack (unlimited reuse) via dp.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Start by defining the DP state `dp[i][w]` as the maximum value achievable with the first `i` items and a knapsack capacity of `w`.
Derive the recurrence relation for `dp[i][w]` considering both the inclusion and exclusion of the `i-th` item, accounting for unlimited reuse.
Optimize the space complexity by reducing the 2D DP table to a 1D array, leveraging the fact that `dp[i][w]` depends only on `dp[i-1][w]` and `dp[i][w - weight[i]]`.
Solve unbounded knapsack (unlimited reuse) via DP
Analyze the solve unbounded knapsack (unlimited reuse) via dp.