class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
cur = [0]*2
n = len(bills)
for i in range(n):
if bills[i] == 5:
cur[0] += 1
elif bills[i] == 10:
cur[1] += 1
if cur[0] > 0:
cur[0] -= 1
else:
return False
else:
if cur[0]>=1 and cur[1]>=1:
cur[0]-=1
cur[1]-=1
elif cur[0] >= 3:
cur[0]-=3
else:
return False
return True
860.柠檬水找零
最新推荐文章于 2024-08-16 18:55:06 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)