Coin Changing Problem
Given available coin denominations, find the number of ways to make the change for a given amount of money.
Statement
Given an integer array representing coins of different denominations and an integer amount representing a total amount of money, return the number of ways the coins can sum up to the amount.
There is no limit on the number of coins available to you.
Example
Suppose the available coin denominations are , and and the total amount of money is . We can make the change for in the following six ways:
Sample input
([1, 2, 5], 7)
Expected output
6
Try it yourself
#include <iostream>#include <vector>using namespace std;int SolveCoinChange(vector<int>& denominations, int amount) {// TODO: Write - Your - Codereturn -1;}
Naive solution
A naïve solution would be to generate all subsets of coin denominations that sum up to the required amount. This, however, would require us to generate subsets, where is the required sum, and ...
Access this course and 1400+ top-rated courses and projects.