You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin.
3
+
4
+
Note: You can assume that
5
+
6
+
0 <= amount <= 5000
7
+
1 <= coin <= 5000
8
+
the number of coins is less than 500
9
+
the answer is guaranteed to fit into signed 32-bit integer
10
+
11
+
12
+
13
+
Example 1:
14
+
15
+
Input: amount = 5, coins = [1, 2, 5]
16
+
Output: 4
17
+
Explanation: there are four ways to make up the amount:
18
+
5=5
19
+
5=2+2+1
20
+
5=2+1+1+1
21
+
5=1+1+1+1+1
22
+
23
+
24
+
25
+
Example 2:
26
+
27
+
Input: amount = 3, coins = [2]
28
+
Output: 0
29
+
Explanation: the amount of 3 cannot be made up just with coins of 2.
0 commit comments