Lemonade Change

Lemonade costs $5. Customers arrive in the order given by bills; each customer pays with one $5, "0, or $20 bill. Initially your till is empty. Give every…

Lemonade costs $5. Customers arrive in the order given by `bills`; each customer pays with one $5, "0, or $20 bill. Initially your till is empty. Give every customer the exact change immediately using bills already in the till, then keep their payment. Return `true` if you can serve the whole queue, or `false` if any customer cannot receive exact change.

- `1 <= bills.length <= 10^5` - `bills[i]` is exactly `5`, `10`, or `20` - The interactive visualizer accepts at most 20 bills; longer valid coding inputs are execution-only.

Example 1: input bills = [5, 5, 10, 5, 20]; output true. The $20 customer receives one "0 and one $5 bill.

Example 2: input bills = [5, 5, 10, 10, 20]; output false. At the last customer the till has two "0 bills but no $5 bill, so it cannot make "5.

Example 3: input bills = [10]; output false. The first customer needs $5 change, but the till is empty.

Category: Greedy Algorithms. Topic: greedy. Difficulty: Easy. Patterns: greedy.