Unbounded knapsack counting combinations (order doesn’t matter).
dp[a] = number of ways to make sum a.
Iterate coins outermost; for each coin c, update a from c..amount:
dp[a] += dp[a-c].
Processing coins in outer loop ensures each combination is counted once (in non-decreasing coin order).
Unbounded knapsack counting combinations (order doesn’t matter).
dp[a] = number of ways to make sum a.
Iterate coins outermost; for each coin c, update a from c..amount:
dp[a] += dp[a-c].
Processing coins in outer loop ensures each combination is counted once (in non-decreasing coin order).