Coin change ways

Write codeMedium20 minAmazon style

Your task

Given an integer amount and a list of distinct positive coin denominations (unlimited supply of each), return the number of distinct combinations of coins that sum to exactly amount. Combinations are unordered, so {1,2} and {2,1} count once. Return 0 if it cannot be made; amount may be 0 (one way: use no coins).

Examples

coin_combinations(amount: int, coins: list[int]) -> int
Example 1
Inputcoin_combinations(5, [1, 2, 5])
Output4