Change-making feasibility
Smoothies cost exactly 5 dollars at a street stand. Customers pay one at a time, each with a single bill: a 5, a 10, or a 20 (given in order as bills). The stand opens with no cash and must give every customer exact change using bills collected so far. Return True if every customer can be served in order. Example: bills [5, 5, 10, 20] is True.
Implement
can_serve_all(bills: list[int]) → boolExamples
in
[[5,5,10,20]]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
[[5,5,10,20]]truenot run yetsample