Skip to content

Commit 806c66b

Browse files
William FisetWilliam Fiset
William Fiset
authored and
William Fiset
committed
Coin change slides
1 parent bea536f commit 806c66b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
296 KB
Binary file not shown.

src/main/java/com/williamfiset/algorithms/dp/CoinChange.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static Solution coinChange(int[] coins, final int n) {
6666
}
6767
}
6868

69-
p(dp);
69+
// p(dp);
7070

7171
Solution solution = new Solution();
7272

@@ -83,6 +83,9 @@ public static Solution coinChange(int[] coins, final int n) {
8383
if (canSelectCoin && dp[coinIndex][change - coinValue] < dp[coinIndex][change]) {
8484
solution.selectedCoins.add(coinValue);
8585
change -= coinValue;
86+
} else if (canSelectCoin && dp[coinIndex][change - coinValue] == dp[coinIndex][change]) {
87+
System.out.println("here");
88+
change -= coinValue;
8689
} else {
8790
coinIndex--;
8891
}

0 commit comments

Comments
 (0)