bumpsoo 2024-08-15 14:44:59 +09:00
parent c91899827b
commit e6c5de02e1

24
easy/lemonade_change.py Normal file
View file

@ -0,0 +1,24 @@
# https://leetcode.com/problems/lemonade-change
from typing import List
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
inventory: List[int] = [0, 0]
for bill in bills:
match bill:
case 5:
inventory[0] += 1
case 10:
inventory[0] -= 1
inventory[1] += 1
if inventory[0] < 0:
return False
case 20:
if inventory[1] == 0:
inventory[0] -= 3
else:
inventory[1] -= 1
inventory[0] -= 1
if inventory[0] < 0 or inventory[1] < 0:
return False
return True