Concept Flow - 0 1 Knapsack Problem
Start with empty knapsack
For each item i
For each weight w from 0 to W
Check if item i fits (weight[i
Include item i: value[i
Update dp[i
Repeat for all items and weights
Final answer in dp[n
We fill a table dp where each cell dp[i][w] stores the best value using first i items with max weight w. For each item and weight, we decide to include or exclude the item to maximize value.