Skip to main content
Advanced~8 min · +40 XP

DP: Coin Change Ways

Practices: Dynamic Programming

Problem

Coins: [1, 3, 4]. Amount: 6. You count the number of DISTINCT combinations that sum to 6 (order doesn't matter: {3,3} is one way, {1,1,4} is another).

How many combinations are there?

Examples

  • in: coins [2, 3], amount 4

    out: 1

    Only 2+2. (3 + one coin can't reach 4.)

Constraints & conventions

  • Unlimited supply of each coin. Combinations, not permutations.

Your answer

Solve the challenge to unlock the full approach and complexity analysis.