일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- heap
- codeup
- 파이썬알고리즘
- two-pointer
- 리트코드
- GenerativeAI
- LeetCode
- 파이썬기초100제
- 생성형AI
- stratascratch
- dfs
- 코드업
- 니트코드
- Python3
- gcp
- Stack
- 투포인터
- sql코테
- SQL
- 릿코드
- 파이썬
- 알고리즘
- GenAI
- 자연어처리
- slidingwindow
- nlp
- array
- Greedy
- 슬라이딩윈도우
- Python
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 |