Coin Change
EasyArrayStringRecursionGREEDY
## 💰 Coin Change Problem
Problem Statement:
You are given an array of coins representing their denominations and an integer amount representing a total amount of money.
Write a function to compute the fewest number of coins needed to make up that amount.
If that amount cannot be made up by any combination of the coins, return -1.
You may assume that you have an infinite supply of each type of coin.
---
### Example
Input:
coins = [1, 2, 5], amount = 11
Output:
3
Explanation:
The minimum number of coins to make 11 is:
11 = 5 + 5 + 1
---
### Constraints
* 1 ≤ coins.length ≤ 12
* 1 ≤ coins[i] ≤ 2³¹ − 1
* 0 ≤ amount ≤ 10⁴
* All elements in coins are unique
Examples
Example 1
Input: [1, 2, 5], 11
Output: 3
Example 2
Input: [2], 3
Output: -1