mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-22 19:59:09 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -7,17 +7,21 @@ public class CoinChange {
|
||||
|
||||
// Driver Program
|
||||
public static void main(String[] args) {
|
||||
|
||||
int amount = 12;
|
||||
int[] coins = {2, 4, 5};
|
||||
int[] coins = { 2, 4, 5 };
|
||||
|
||||
System.out.println(
|
||||
"Number of combinations of getting change for " + amount + " is: " + change(coins, amount));
|
||||
"Number of combinations of getting change for " +
|
||||
amount +
|
||||
" is: " +
|
||||
change(coins, amount)
|
||||
);
|
||||
System.out.println(
|
||||
"Minimum number of coins required for amount :"
|
||||
+ amount
|
||||
+ " is: "
|
||||
+ minimumCoins(coins, amount));
|
||||
"Minimum number of coins required for amount :" +
|
||||
amount +
|
||||
" is: " +
|
||||
minimumCoins(coins, amount)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,7 +33,6 @@ public class CoinChange {
|
||||
* number of combinations of change
|
||||
*/
|
||||
public static int change(int[] coins, int amount) {
|
||||
|
||||
int[] combinations = new int[amount + 1];
|
||||
combinations[0] = 1;
|
||||
|
||||
@ -64,7 +67,10 @@ public class CoinChange {
|
||||
for (int coin : coins) {
|
||||
if (coin <= i) {
|
||||
int sub_res = minimumCoins[i - coin];
|
||||
if (sub_res != Integer.MAX_VALUE && sub_res + 1 < minimumCoins[i]) {
|
||||
if (
|
||||
sub_res != Integer.MAX_VALUE &&
|
||||
sub_res + 1 < minimumCoins[i]
|
||||
) {
|
||||
minimumCoins[i] = sub_res + 1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user