Medium
Quiz
#322 Coin Change
APPROACH
An array coins holds denominations of available currency, with unlimited coins of each type. Given a target integer amount, find the smallest number of coins whose values sum to exactly amount. If no valid combination can reach amount, return -1.
Example 1:
Input: coins = [1,2,5], amount = 11
Output: 3
Explanation: 11 = 5 + 5 + 1
Example 2:
Input: coins = [2], amount = 3
Output: -1
Example 3:
Input: coins = [1], amount = 0
Output: 0
1 of 4
1:00
What is the optimal approach for this problem?