Coin Change II

Medium

Topics
ArrayDynamic Programming

You are given coin denominations nums and a target amount k. Return the number of distinct combinations that make up the amount (order does not matter). Return 0 if impossible.

Example 1

Input:  nums = [1,2,5], k = 5
Output: 4

Example 2

Input:  nums = [2], k = 3
Output: 0

Constraints

  • 1 <= nums.length <= 300
  • 1 <= nums[i] <= 5000
  • 0 <= k <= 5000
Run ⌘' · Submit ⌘⏎