11 backpacks

这里有6个背包问题,方法主要是把值作为其中一维,把能选的元素作为另外一位(前i个元素)。根据能不能重复取元素dp公式会有变化.

Note: bounded backpack 1 dim optimization inner loop need to pick item from back. Unbounded inner loop can pick from beginning.

L92 Backpack

L125 Backpack II

L440 Backpack III

L562 Backpack IV

L563 Backpack V

L564 Backpack VI

Other Related:

L279 Number of Ways to Represent N Cents - IV

279 Perfect Squares -- 听说还能bfs,两年后回刷,还真能bfs;然后数学解法是四平方定理,然后还能递归,还有另一种DP解法。太高级,有空再补

322 Coin Change

39 Combination Sum I 求方案数 - IV

40 Combination Sum II 求方案数 - V

377 Combination Sum IV -- backpack VI

416 Partition Equal Subset Sum

474 Ones and Zeroes

Last updated