← Back to Learn
0-1 Knapsack
Pack items to maximize total value within a weight capacity. Watch the DP table fill cell-by-cell, then backtrack to find the optimal selection.
0/63
speed
5
items
12
capacity
0
best value
0/12
weight
items 5
capacity 12
seed ⓘ 42
setup
Initialize: 5 items, capacity 12. DP table is (6)×(13), all zeros.
complexity
O(nW)