Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

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 ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access