You are viewing a single comment's thread. Return to all comments →
short c++ solution using interative dynamic programming
long getWays(int n, vector<long> c) { vector<long> dp(n+1,0); dp[0]=1; int cs = c.size(); for (int i = 0; i < cs; i++) { int coin = c[i]; for (int j = coin; j <= n; j++) { dp[j] += dp[j-coin]; } } return dp[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 →
short c++ solution using interative dynamic programming