diff --git a/Problem1.java b/Problem1.java new file mode 100644 index 00000000..2c21861d --- /dev/null +++ b/Problem1.java @@ -0,0 +1,34 @@ +// Time Complexity : O(MXN) M is the total number of coins and N is the lenght of Array +// Space Complexity : O(N) +// Did this code successfully run on Leetcode : Yes +// Any problem you faced while coding this :Initialise the Array with Max Value when looking for the Minimum + + +// Your code here along with comments explaining your approach +class Solution{ + int coinChange(int coins[], int amount){ + //Edge Case + if(amount<1){ + return 0; + } + else{ + // Make an array starting from 0 to the Max amount in the array so that at each position we check the mimum coints to reach that particular value + int minCoinsDP[]=new int[amount+1]; + for(int i=1; i