We’re preparing your current view and syncing the latest data.
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.
Given an integer array bills where bills[i] is the bill the customer pays, return true if you can provide every customer with the correct change, or false otherwise.
clike
Input: bills = [5,5,5,10,20]
Output: true
Explanation:
- Customer 1 pays $5, no change needed.
- Customer 2 pays $5, no change needed.
- Customer 3 pays $5, no change needed.
- Customer 4 pays $10, give one $5 as change.
- Customer 5 pays $20, give one $10 and one $5 as change.clike
Input: bills = [5,5,10]
Output: trueclike
Input: bills = [10,10]
Output: false
Explanation: Cannot provide change to the first customer who pays $10.An integer array bills of length , representing the sequence of bills given by customers.
Return true if it is possible to give every customer the correct change, otherwise return false.
1 <= bills.length <= 10^5 bills[i] ∈ {5, 10, 20}