State: dp[i][w] = max value using items 0…i with capacity w.
Choice at each item: Key constraint: Each item can only be taken once (0/1), so we look at the previous row dp[i-1], never the same row.
Filled cell
Current cell
Source cells
Optimal path

Controls

Time: O(n·W) | Space: O(n·W)

Steps

0 steps

Press Run to trace the algorithm one step at a time.