Soal
00:00

23. Coin Change

SedangPemrograman dinamisAmazonMicrosoft

Given coin denominations and an amount, return the minimum number of coins needed, or -1 if the amount cannot be formed.

Contoh 1:

Input: coins = [1,2,5], amount = 11
Output: 3

Contoh 2:

Input: coins = [2], amount = 3
Output: -1

Batasan:

  • 1 <= coins.length <= 12
  • 0 <= amount <= 10^4
Mode kode inti
● Tersimpan otomatisBaris 1, kolom 1