1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/**
* You are given an integer array coins representing coins of different
* denominations and an integer amount representing a total amount of money.
* <p>
* Return the number of combinations that make up that amount. If that amount of
* money cannot be made up by any combination of the coins, return 0.
* <p>
* You may assume that you have an infinite number of each kind of coin.
* <p>
* The answer is guaranteed to fit into a signed 32-bit integer.
* <p>
* <p>
* Example 1:
* <p>
* <p>
* Input: amount = 5, coins = [1,2,5]
* Output: 4
* Explanation: there are four ways to make up the amount:
* 5=5
* 5=2+2+1
* 5=2+1+1+1
* 5=1+1+1+1+1
* <p>
* <p>
* Example 2:
* <p>
* <p>
* Input: amount = 3, coins = [2]
* Output: 0
* Explanation: the amount of 3 cannot be made up just with coins of 2.
* <p>
* <p>
* Example 3:
* <p>
* <p>
* Input: amount = 10, coins = [10]
* Output: 1
* <p>
* <p>
* <p>
* Constraints:
* <p>
* <p>
* 1 <= coins.length <= 300
* 1 <= coins[i] <= 5000
* All the values of coins are unique.
* 0 <= amount <= 5000
* <p>
* <p>
* Related Topics Array Dynamic Programming 👍 9337 👎 168
*/
/*
2024-07-17 23:12:37
Coin Change II
Category Difficulty Likes Dislikes
algorithms Medium (63.80%) 9337 168
*/
|