-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlemonade_change.py
More file actions
30 lines (30 loc) · 905 Bytes
/
Copy pathlemonade_change.py
File metadata and controls
30 lines (30 loc) · 905 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
26
27
28
29
30
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
x = []
for i in bills:
if i == 5:
x.append(5)
elif i == 10:
if 5 in x:
x.remove(5)
x.append(10)
else:
return False
elif i == 20:
val = Counter(x)
t = val.get(5)
t1 = val.get(10)
if t == None:
return False
if t1 == None:
if t >= 3:
for i in range(3):
x.remove(5)
x.append(20)
else:
return False
else:
x.remove(5)
x.remove(10)
x.append(20)
return True