We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0902810 commit 865bd48Copy full SHA for 865bd48
solution/0860.Lemonade Change/Solution.java
@@ -0,0 +1,25 @@
1
+class Solution {
2
+ public boolean lemonadeChange(int[] bills) {
3
+ int fives = 0, tens = 0;
4
+ for (int bill : bills) {
5
+ if (bill == 5) {
6
+ ++fives;
7
+ } else if (bill == 10) {
8
+ ++tens;
9
+ if (--fives < 0) {
10
+ return false;
11
+ }
12
+ } else {
13
+ if (tens >= 1 && fives >= 1) {
14
+ --tens;
15
+ --fives;
16
+ } else if (fives >= 3) {
17
+ fives -= 3;
18
19
20
21
22
23
+ return true;
24
25
+}
0 commit comments