Code Room
CodingEasycod-g1446
Subject GreedyLevel Entry–Mid~12 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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]) → bool
Examples
in[[5,5,10,20]]outtrue
What 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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.