Apex › Storage & databases

0/1 Knapsack (dynamic programming)

Pick a subset of items to maximize value within a weight budget — where greedy fails and DP wins. Watch the table fill row by row, read the answer off the bottom-right corner, and follow the highlighted backtrack path to see which items were chosen. The greedy-by-ratio result is shown losing alongside.

More in Storage & databases