From b82aaa1991d9173522c1e8af4659d241fb3bf412 Mon Sep 17 00:00:00 2001 From: JuhunC <31757586+JuhunC@users.noreply.github.com> Date: Wed, 25 Jul 2018 21:58:24 +0900 Subject: [PATCH] Update CoinChange.java Added Coin Combination of Minimum Number of CoinChange --- Dynamic Programming/CoinChange.java | 55 +++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/Dynamic Programming/CoinChange.java b/Dynamic Programming/CoinChange.java index f4cda7203b7c..18550c73ea05 100644 --- a/Dynamic Programming/CoinChange.java +++ b/Dynamic Programming/CoinChange.java @@ -1,7 +1,7 @@ /** * * @author Varun Upadhyay (https://github.com/varunu28) - * + * @contributor Choi Ju Hun (https://github.com/JuhunC) */ public class CoinChange { @@ -13,8 +13,59 @@ public static void main(String[] args) { int[] coins = {1, 2, 5}; System.out.println("Number of combinations of getting change for " + amount + " is: " + change(coins, amount)); + System.out.println("Combination is : "); + int[] result = minChange(coins,amount); + int sum =0; + for(int i =0;i= 1) { + if(coin[i-coins[m]]+1 < coin[i]) { + coin[i] = coin[i-coins[m]] +1; + for(int k=0;k