We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The Coin Change Problem
The Coin Change Problem
Sort by
recency
|
724 Discussions
|
Please Login in order to post a comment
Explanation:
getWays
function initializes an array$ways
with zeros and setsways[0]
to 1 because there's exactly one way to make change for 0 (using no coins).$ways
array by adding the number of ways to make change for the amount minus the coin's value.n
is returned.Input Format:
The input is read from
php://stdin
: - The first line contains two space-separated integersn
andm
: -n
is the amount to change. -m
is the number of different coin denominations. - The second line containsm
space-separated integers representing the coin denominations.-c++ code
int rec(int n,vector&c) { int s=c.size(); vectorway(n+1,0); way[0]=1;
}
signed main() { // memset(dp, -1, sizeof(dp)); int n,m; cin >> n>>m; vectorv(m); for(int i=0;i>v[i]; int ans=rec(n,v); cout<
}
This is not much. But an honest work
PHP Recursion Solution Source: GeeksForGeeks!