Skip to content

Commit e213706

Browse files
Create readme.md
1 parent 80e7aea commit e213706

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Lemonade Change/readme.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
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.
2+
3+
Note that you do not have any change in hand at first.
4+
5+
Given an integer array bills where bills[i] is the bill the ith customer pays, return true if you can provide every customer with the correct change, or false otherwise.
6+
7+
8+
9+
Example 1:
10+
11+
Input: bills = [5,5,5,10,20]
12+
Output: true
13+
Explanation:
14+
From the first 3 customers, we collect three $5 bills in order.
15+
From the fourth customer, we collect a $10 bill and give back a $5.
16+
From the fifth customer, we give a $10 bill and a $5 bill.
17+
Since all customers got correct change, we output true.
18+
Example 2:
19+
20+
Input: bills = [5,5,10,10,20]
21+
Output: false
22+
Explanation:
23+
From the first two customers in order, we collect two $5 bills.
24+
For the next two customers in order, we collect a $10 bill and give back a $5 bill.
25+
For the last customer, we can not give the change of $15 back because we only have two $10 bills.
26+
Since not every customer received the correct change, the answer is false.
27+
28+
29+
Constraints:
30+
31+
1 <= bills.length <= 105
32+
bills[i] is either 5, 10, or 20.

0 commit comments

Comments
 (0)