Problem
You get an integer array coins and an integer amount. Each item in coins is the value of one type of coin. You have an unlimited number of coins of each type.
Return the minimum number of coins that add up to exactly amount. If no group of coins adds up to amount, return -1.
Example 1
- Input:
- coins = [1,4,6], amount = 8
- Output:
- 2
- Explanation:
4 + 4is 8 and uses 2 coins. If you take the 6 first, you need6 + 1 + 1, which uses 3 coins.
Example 2
- Input:
- coins = [4], amount = 7
- Output:
- -1
- Explanation:
- Each total that you make with coins of value 4 is a multiple of 4. The amount 7 is not a multiple of 4.
Example 3
- Input:
- coins = [3,5], amount = 0
- Output:
- 0
- Explanation:
- The amount 0 needs no coins.
Constraints
- 1 <= coins.length <= 12
- 1 <= coins[i] <= 2^31 - 1
- 0 <= amount <= 10^4
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Last Stone Weight II
Coding · 0-1 Knapsack · Array · Dynamic Programming
- Partition Equal Subset Sum
Coding · 0-1 Knapsack · Array · Dynamic Programming
- Target Sum
Coding · 0-1 Knapsack · Array · Backtracking
- Accounts Merge
Coding · Array · Breadth-First Search · Depth-First Search
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 4 records
Amazon
Leetcode 322. Coin Change
Reported Nov 1, 2025 · 2 source reports
JUNIOR, MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceGoogle
Leetcode 322. Coin Change
Reported Sep 29, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourcePinterest
Leetcode 322. Coin Change
Reported Oct 1, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceUber
Leetcode 322. Coin Change
Reported May 6, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source