Tap here to switch tabs
Problem
Submissions

Problem: Coin Change

Coin Change gives a target amount and coin denominations, each available in unlimited quantity. Find the fewest coins needed, or return -1 if the amount cannot be formed, with zero requiring zero coins.

Statement

Given an integer total that represents the target amount of money and a list of integers coins that represents different coin denominations, find the minimum number of coins required to make up the total amount. If it’s impossible to achieve the target amount using the given coins, return -1. If the target amount is 0, return 0.

Note: You can assume that we have an infinite number of each kind of coin.

Constraints:

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

  • 1≤1 \leq coins[i] ≤104\leq 10^4

  • 0≤0 \leq total ≤900\leq 900

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Coin Change

Coin Change gives a target amount and coin denominations, each available in unlimited quantity. Find the fewest coins needed, or return -1 if the amount cannot be formed, with zero requiring zero coins.

Statement

Given an integer total that represents the target amount of money and a list of integers coins that represents different coin denominations, find the minimum number of coins required to make up the total amount. If it’s impossible to achieve the target amount using the given coins, return -1. If the target amount is 0, return 0.

Note: You can assume that we have an infinite number of each kind of coin.

Constraints:

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

  • 1≤1 \leq coins[i] ≤104\leq 10^4

  • 0≤0 \leq total ≤900\leq 900