Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -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;
}
}