690. Lemonade Change
0
Easy
In a **lemonade stand**, each lemonade costs $5. Customers are lining up to buy from you and they order one at a time, following the order specified by the bills. Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. Your task is to provide the correct change to each customer so that the net transaction is that the customer pays $5.
Note that you start with no change in hand.
Given an integer array bills where bills[i] represents the bill the ith customer pays, determine if you can provide every customer with the correct change. Print true if you can, or false otherwise.
Input Format
The first line contains an integer N, representing the number of customers.
The second line contains an integer array of size N, representing the bills paid by each customer.
Output Format
Print True or False.
Example
Input
5
5 5 10 10 20
Output
False
Constraints
1 <= N <= 10^5
bills[i] can only be 5, 10, or 20.
Loading...
View Submissions
Console