cheetcode

114. Coin Change IIMedium

Count how many coin combinations can form a target amount.

Given an integer amount and an array of coin denominations, return the number of combinations that make up that amount.

You may use each coin denomination any number of times.

Examples

Input: amount = 5, coins = [1,2,5]
Output: 4
Input: amount = 3, coins = [2]
Output: 0

Constraints

  • 0 <= amount <= 5000
  • 1 <= coins.length <= 300
  • 1 <= coins[i] <= 5000