Concept Flow - 0 1 Knapsack Problem
Start with empty DP table
For each item i
For each weight w from 0 to max
Check if item i fits in weight w
Include item i: value = val[i
Exclude item i: value = dp[i-1
Choose max(include, exclude)
Fill dp[i
Repeat for all items and weights
Answer = dp[last_item
We build a table where each cell shows the best value for items up to i and weight w, choosing to include or exclude the current item.