LeetCode 322 Coin Change - Problem Statement

The problem

Given coin denominations and a target amount, find the minimum number of coins needed to make that amount. Return −1-1 if impossible.

With coins = [1,2,5] and amount = 11:

  • 11=5+5+111 = 5 + 5 + 1: 33 coins.
  • 11=5+2+2+211 = 5 + 2 + 2 + 2: 44 coins.
  • Minimum: 33.

With coins = [2] and amount = 3:

  • Can't make 33 with only 22-coins.
  • Return −1-1.

You can use each coin denomination unlimited times.

Constraints: 1≤1 \le coins.length ≤12\le 12. 1≤1 \le amount ≤104\le 10^4.