← All problems
Coin Change
Given coin denominations and a target amount, find the fewest coins needed to make up that amount; return -1 if it is impossible. You may use each denomination any number of times.
Complexity
Time O(amount * coins), Space O(amount)
Common pitfalls
- Greedy coin choice
- Wrong loop order confusion with counting variant
Your solution
Log in to save your code and track progress.