Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

amount =
coins =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Unbounded knapsack counting combinations (order doesn’t matter).

Approach

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].

Why it works

Processing coins in outer loop ensures each combination is counted once (in non-decreasing coin order).

Code
Loading...
Complexity
Time: O(amount * numCoins)
Space: O(amount)
Solution
Updated: 2026-02-23

Idea

Unbounded knapsack counting combinations (order doesn’t matter).

Approach

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].

Why it works

Processing coins in outer loop ensures each combination is counted once (in non-decreasing coin order).

Code
Loading...
Complexity
Time: O(amount * numCoins)
Space: O(amount)