@@ -0,0 +1,652 @@
+package algorithms.coinchange;%0A%0Aimport java.util.Scanner;%0A%0Apublic class Solution %7B%0A%0A%09private static long makeChange(int%5B%5D coins, int amount) %7B%0A%09%09int%5B%5D solutions = new int%5Bamount + 1%5D;%0A%0A%09%09solutions%5B0%5D = 1;%0A%0A%09%09for (int coin : coins) %7B%0A%09%09%09for (int j = coin; j %3C= amount; j++) %7B%0A%09%09%09%09solutions%5Bj%5D += solutions%5Bj - coin%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return solutions%5Bamount%5D;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Scanner in = new Scanner(System.in);%0A%09%09int n = in.nextInt();%0A%09%09int m = in.nextInt();%0A%09%09int coins%5B%5D = new int%5Bm%5D;%0A%09%09for (int coins_i = 0; coins_i %3C m; coins_i++) %7B%0A%09%09%09coins%5Bcoins_i%5D = in.nextInt();%0A%09%09%7D%0A%09%09System.out.println(makeChange(coins, n));%0A%09%7D%0A%7D%0A

solve coin change problem with dp