diff --git a/problem1.java b/problem1.java new file mode 100644 index 00000000..e0620f0a --- /dev/null +++ b/problem1.java @@ -0,0 +1,30 @@ +// Time Complexity : O(m*n) +// Space Complexity : O(m*n) +// Did this code successfully run on Leetcode : Yes +// Any problem you faced while coding this : No + + + +class Solution { + public int coinChange(int[] coins, int amount) { + int m = coins.length; + int n = amount; + int[][] dp = new int[m+1][n+1]; + dp[0][0] = 0; + for(int i=1;i<=n;i++){ + dp[0][i] = 999999; + } + for(int i=1;i<=m;i++){ + for(int j=0;j<=n;j++){ + if(j