⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 24s17 days 22 hours 20 minutes 24 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 24s17 days 22 hours 20 minutes 24 seconds.

Sign in to watch this lesson
Algorithms - Dynamic Programming · 4:36
Each item exists once and has a weight and a value: with items (3, 4) and (4, 5) and a bag of capacity 7, the table f[i][j] = max(f[i-1][j], f[i-1][j-w] + v) reaches 9. We squeeze it into one row and watch the loop direction decide the problem: sweeping j downward reads only the old row (0/1 knapsack), while the same line sweeping upward reads freshly updated cells and takes an item twice (unbounded knapsack). Then bounded knapsack by binary splitting (13 copies become bundles 1, 2, 4, 6; about 40 times faster than copy by copy on this Mac), exact-capacity initialisation, subset sum with bitset shifts, value-indexed tables for huge capacities, and the capital-allocation framing used in quant interviews.