Question
The Minimum Coin Vault
You are given an array
Complete the function
Input
The first line contains an integer KaTeX can only parse string typed expression — the number of coin denominations.
The second line contains KaTeX can only parse string typed expression space-separated integers.
The third line contains the integer KaTeX can only parse string typed expression.
Output
A single integer — the minimum number of coins needed, or KaTeX can only parse string typed expression if impossible.
Example
Example 1:
Input
11 = 5+5+1, using 3 coins.
Example 2:
Input
Amount 3 cannot be made with only 2-coins.
Example 3:
Input
Zero coins needed to make amount 0.
Input
3
1 2 5
11Output3Explanation11 = 5+5+1, using 3 coins.
Example 2:
Input
1
2
3Output-1ExplanationAmount 3 cannot be made with only 2-coins.
Example 3:
Input
1
1
0Output0ExplanationZero coins needed to make amount 0.