Description
At a lemonade stand, each lemonade costs . Customers pay with , , or bills. Return true if you can provide correct change to every customer, starting with no money.
Examples
Input:
bills = [5,5,5,10,20]Output:
trueExplanation:
Can give change for all.
Input:
bills = [5,5,10,10,20]Output:
falseExplanation:
After two $5 and two $10 bills, the $20 customer needs $15 change, but only one $5 bill remains.
Input:
bills = [5,5,20]Output:
falseExplanation:
First two customers pay with $5 bills, providing two $5 bills as change. The third customer pays with a $20 bill, requiring $15 change, but only two $5 bills (total $10) are available. $15 change cannot be made without a $10 bill.
Constraints
- •
1 ≤ bills.length ≤ 10⁵