Tap here to switch tabs
Problem
Submissions

Problem: Coin Change II

Coin Change II gives an amount and an array of coin denominations. Count distinct combinations that sum exactly to it, using each denomination any number of times and ignoring order.

Statement

Given an integer amount and an array coins where each value represents a coin denomination, return the number of distinct combinations that sum exactly to amount. You may use each coin denomination in coins any number of times, and the order of coins in a combination does not matter.

Note: A combination is defined by the counts of each denomination used, not by the sequence in which coins are chosen.

Constraints:

  • 1≤1 \leq coins.length ≤300\leq 300

  • 1≤1 \leq coins[i] ≤5000\leq 5000

  • All values in coins are unique.

  • 0≤0 \leq amount ≤5000\leq 5000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Coin Change II

Coin Change II gives an amount and an array of coin denominations. Count distinct combinations that sum exactly to it, using each denomination any number of times and ignoring order.

Statement

Given an integer amount and an array coins where each value represents a coin denomination, return the number of distinct combinations that sum exactly to amount. You may use each coin denomination in coins any number of times, and the order of coins in a combination does not matter.

Note: A combination is defined by the counts of each denomination used, not by the sequence in which coins are chosen.

Constraints:

  • 1≤1 \leq coins.length ≤300\leq 300

  • 1≤1 \leq coins[i] ≤5000\leq 5000

  • All values in coins are unique.

  • 0≤0 \leq amount ≤5000\leq 5000