Re: [閒聊] 每日leetcode

作者: dont   2024-08-16 00:08:23
860. Lemonade Change
## 思路
就照題目模擬, 5元直接收下, 10元找5元, 20元找15元
## Code
```python
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
coin = [0, 0]
for bill in bills:
if bill == 5:
coin[0] += 1
elif bill == 10:
if coin[0]:
coin[0] -= 1
else:
return False
coin[1] += 1
else:
if coin[1] and coin[0]:
coin[0] -= 1
coin[1] -= 1
elif coin[0] > 2:
coin[0] -= 3
else:
return False
return True
```
作者: CanIndulgeMe (CIM)   2024-08-16 00:09:00
技術大神
作者: oin1104 (是oin的說)   2024-08-16 00:19:00
我快哭了 你好強

Links booklink

Contact Us: admin [ a t ] ucptt.com