Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 529 Bytes

File metadata and controls

30 lines (21 loc) · 529 Bytes

Lemonade Change

Description

link


Solution

  • See Code

Code

Complexity T : O(N)

class Solution:
    def lemonadeChange(self, bills: List[int]) -> bool:
        five = ten = 0
        for i in bills:
            if i == 5: five += 1
            elif i == 10: five, ten = five - 1, ten + 1
            elif ten > 0: five, ten = five - 1, ten - 1
            else: five -= 3
            if five < 0: return False
        return True