-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path352.py
More file actions
26 lines (21 loc) · 667 Bytes
/
352.py
File metadata and controls
26 lines (21 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
money = [0, 0, 0]
for bill in bills:
if bill == 5:
money[0] += 1
elif bill == 10:
money[0] -= 1
if money[0] < 0:
return False
money[1] += 1
else:
if money[1] > 0 and money[0] > 0:
money[1] -= 1
money[0] -= 1
elif money[0] > 2:
money[0] -= 3
else:
return False
money[2] += 1
return True