1154. Coin Change II — Number of Ways

EasyDynamic ProgrammingUnbounded KS

Given coin denominations (unlimited supply) and an amount, return the number of distinct combinations that make up the amount. Order does not matter. The input is JSON {amount, coins}.

Input: JSON {amount, coins}.

Output: Integer — the number of combinations.

Examples

Example 1
Input: {"amount":5,"coins":[1,2,5]}
Output: 4
Explanation: Four combinations.
Example 2
Input: {"amount":4,"coins":[2]}
Output: 1
Explanation: 2+2.
Example 3
Input: {"amount":0,"coins":[1]}
Output: 1
Explanation: The empty combination.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →