| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- codeup
- 코드업
- graph
- Greedy
- array
- stratascratch
- LeetCode
- dfs
- 릿코드
- GenAI
- GenerativeAI
- sql코테
- heap
- 생성형AI
- 파이썬
- BFS
- 파이썬알고리즘
- 니트코드
- tree
- 리트코드
- Python3
- SQL
- binary Tree
- nlp
- Python
- 슬라이딩윈도우
- Stack
- 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/Greedy] 1323. Maximum 69 Number (0) | 2025.05.23 |
|---|---|
| [Leetcode/Array, Greedy] 976. Largest Perimeter Triangle (0) | 2025.05.23 |
| [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 |