일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- stratascratch
- tree
- 코드업
- Stack
- nlp
- codeup
- 슬라이딩윈도우
- slidingwindow
- 알고리즘
- 파이썬
- 생성형AI
- 자연어처리
- dfs
- Python3
- 파이썬기초100제
- gcp
- 니트코드
- LeetCode
- medium
- 리트코드
- 릿코드
- sql코테
- 투포인터
- 파이썬알고리즘
- GenAI
- Python
- heap
- GenerativeAI
- SQL
- two-pointer
Archives
- Today
- Total
Tech for good
[Leetcode/Array, Greedy] 860. Lemonade Change 본문
class Solution:
def lemonadeChange(self, bills: List[int]) -> bool:
five, ten = 0, 0
for bill in bills:
if bill == 5:
five += 1
elif bill == 10:
if five == 0:
return False
five -= 1
ten += 1
else:
if ten > 0 and five > 0:
ten -= 1
five -= 1
elif five >= 3:
five -= 3
else:
return False
return True
'IT > Computer Science' 카테고리의 다른 글
[Leetcode/Sort, Greedy, Two-pointer] 455. Assign Cookies (0) | 2025.05.03 |
---|---|
[Leetcode/Sort, Greedy] 561. Array Partition (0) | 2025.05.02 |
[Leetcode/Stack,Queue] 1700. Number of Students Unable to Eat Lunch (0) | 2025.04.22 |
[Leetcode/Stack] 1614. Maximum Nesting Depth of the Parentheses (0) | 2025.04.21 |
[Leetcode/Stack,Tree] 897. Increasing Order Search Tree (0) | 2025.04.16 |