We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 661ed3f + 48884c1 commit 80b64afCopy full SHA for 80b64af
June-LeetCoding-Challenge/07-Coin-Change-2/Coin-Change-2.java
@@ -0,0 +1,15 @@
1
+class Solution {
2
+ public int change(int amount, int[] coins) {
3
+ int[] combinations = new int[amount + 1];
4
+ combinations[0] = 1;
5
+ for (int coin : coins) {
6
+ for (int i = coin; i <= amount; i++) {
7
+ int prev = i - coin;
8
+ if (prev >= 0) {
9
+ combinations[i] += combinations[prev];
10
+ }
11
12
13
+ return combinations[amount];
14
15
+}
0 commit comments