You are viewing a single comment's thread. Return to all comments →
Java O(n*m)
public static long getWays(int n, List<Long> c) { long[] ways = new long[n + 1]; ways[0] = 1; for (long coin : c) { for (int i = (int) coin; i <= n; i++) { ways[i] += ways[i - (int) coin]; } } return ways[n]; }
Seems like cookies are disabled on this browser, please enable them to open this website
The Coin Change Problem
You are viewing a single comment's thread. Return to all comments →
Java O(n*m)