O49
Coin Change (Minimum Coins)
Problem Statement & Objective
You are given an integer array coins representing coins of different denominations and an integer amount. Return the fewest number of coins that you need to make up that amount.
Function Signature (Python)
coin_change_minimum_coins(coins: list[int], amount: int) -> intInput & Output Contract
Output Rule:Minimum para adedi veya -1.
System Constraints
1 <= paralar.length <= 12
1 <= paralar[i] <= 2^31 - 1
0 <= tutar <= 10^4Example Execution Walkthrough
paralar = [1, 2, 5], tutar = 11 -> 5 + 5 + 1 = 11 (3 adet)
paralar = [2], tutar = 3 -> imkansız -> -1
paralar = [1, 3, 4], tutar = 6
Açgözlü 4 + 1 + 1 = 3 para seçer. En az 3 + 3 = 2 paradır. Cevap 2.Example Test Scenarios (4)
Example 1
Input:
[[1,2,5],11]Expected Output:
3Example 2: İmkansız
Input:
[[2],3]Expected Output:
-1Example 3: Sıfır Tutar
Input:
[[1],0]Expected Output:
0Example 4: Açgözlü Yanlış
Input:
[[1,3,4],6]Expected Output:
2