diff --git a/Exercise_1.cs b/Exercise_1.cs new file mode 100644 index 00000000..e69de29b diff --git a/Exercise_2.cs b/Exercise_2.cs new file mode 100644 index 00000000..74abbe96 --- /dev/null +++ b/Exercise_2.cs @@ -0,0 +1,27 @@ +// Time complexity : O(N*amount); +// Space Complexity: O(n*amount); + + +public class Solution { + int count = 0; + public int Change(int amount, int[] coins) { + + if(coins == null) return 0; + int[,] dp = new int[coins.Length + 1 , amount+1]; + dp[0,0] = 1; + for(int j = 1 ;j<=amount;j++){ + dp[0,j] = 0; + } + + for(int i=1;i<=coins.Length;i++){ + for(int j=0;j<=amount;j++){ + if(coins[i-1] > j){ + dp[i,j] = dp[i-1,j]; + }else { + dp[i,j] = dp[i-1,j] + dp[i,j-coins[i-1]]; + } + } + } + return dp[coins.Length,amount]; + } +} \ No newline at end of file