From eb73feb11e23e5cc227d04bbbbb13e4b19bf149e Mon Sep 17 00:00:00 2001 From: Nitishnitj Date: Fri, 28 Jun 2019 12:01:49 +0530 Subject: [PATCH 1/2] please look into the code --- Greedy/Another Coin Problem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Greedy/Another Coin Problem.cpp b/Greedy/Another Coin Problem.cpp index dc171d3..839a09b 100644 --- a/Greedy/Another Coin Problem.cpp +++ b/Greedy/Another Coin Problem.cpp @@ -12,3 +12,4 @@ int Solution::solve(int n) { } return ans; } +//not handling the n=100 case your solution 2 but actual is 1 From be90c0646abd0fba0a887a749ae9e95fa5697aef Mon Sep 17 00:00:00 2001 From: Nitishnitj Date: Fri, 28 Jun 2019 12:06:38 +0530 Subject: [PATCH 2/2] done --- Greedy/Another Coin Problem.cpp | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Greedy/Another Coin Problem.cpp diff --git a/Greedy/Another Coin Problem.cpp b/Greedy/Another Coin Problem.cpp deleted file mode 100644 index 839a09b..0000000 --- a/Greedy/Another Coin Problem.cpp +++ /dev/null @@ -1,15 +0,0 @@ -int Solution::solve(int n) { - long dp[100]; - for(int i = 0; i < 100; i++) dp[i] = 1000; - dp[0] = 0; - for(int i = 1; i < 100; i++) dp[i] = min(dp[i-1] + 1, dp[i]); - for(int i = 10; i < 100; i++) dp[i] = min(dp[i-10] + 1, dp[i]); - for(int i = 25; i < 100; i++) dp[i] = min(dp[i-25] + 1, dp[i]); - long ans = 0; - while(n > 0) { - ans += dp[(int)(n % 100)]; - n /= 100; - } - return ans; -} -//not handling the n=100 case your solution 2 but actual is 1