Lemonade Change
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You run a lemonade stand where each cup costs $5. Customers arrive one at a time in the order given by bills, and each pays with a single $5, $10, or $20 bill. You start with no money at all.
Every customer must receive exact change immediately, using only the bills you have collected from earlier customers (and the bill they just handed you is not usable for their own change beyond keeping it).
Return true if you can give every customer correct change, and false otherwise.
Examples
Constraints
- 1 <= bills.length <= 10^5
- Each `bills[i]` is 5, 10, or 20.
- You start with no bills.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.