K35
Lemonade Change
Problem Statement & Objective
At a lemonade stand, each lemonade costs $5. Customers stand in a queue and pay with $5, $10, or $20 bills. Return True if you can provide every customer with correct change.
Function Signature (Python)
lemonade_change(invoices: list[int]) -> boolInput & Output Contract
Output Rule:True veya False.
System Constraints
1 <= faturalar.length <= 10^5
faturalar[i] ∈ {5, 10, 20}Example Execution Walkthrough
faturalar = [5, 5, 5, 10, 20] -> 20 gelince 10 + 5 verilir -> True
faturalar = [5, 5, 10, 10, 20] -> 20'ye para üstü (15) verilemez -> False
faturalar = [5, 5, 5, 5, 10, 20, 10]
20 geldiğinde kasada üç adet 5 ve bir adet 10 vardır.
10+5 verilirse son 10'a bir 5 kalır -> True.
20'ye üç adet 5 verilirse son 10'a 5 kalmaz -> False.
Doğru seçim 10'u önce harcamaktır. Cevap True.Example Test Scenarios (4)
Example 1
Input:
[[5,5,5,10,20]]Expected Output:
trueExample 2: Para Üstü Biter
Input:
[[5,5,10,10,20]]Expected Output:
falseExample 3: İlk Müşteri 10
Input:
[[10]]Expected Output:
falseExample 4: 20'de 10'u Harca
Input:
[[5,5,5,5,10,20,10]]Expected Output:
true