| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 미드시청
- 읽기
- 화상영어
- 괜찮음
- 링피트
- realclass
- 개발자
- 만화도
- 영어공부
- 영어원서읽기
- leetcode
- 매일
- 뭐든
- 파비최
- FIT XR
- English
- 월간
- 10분
- 프로젝트
- 30분
- 잡생각
- Writing
- 리얼 클래스
- 스탭퍼
- Problem Solving
- 쓰릴오브파이트
- 사이드
- Daily Challenge
- 3줄정리
- 운동
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/minimum-rounds-to-complete-all-tasks/
Minimum Rounds to Complete All Tasks - LeetCode
Minimum Rounds to Complete All Tasks - You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level. Return the minimum rounds requ
leetcode.com
탐욕법으로 간단히 풀수 있음!
class Solution:
def minimumRounds(self, tasks: List[int]) -> int:
freqs = Counter(tasks)
res = 0
for freq in freqs.values():
if freq == 1:
return -1
res += ceil(freq/3)
return res반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2023.01.06 |
|---|---|
| Today's Challenge (0) | 2023.01.05 |
| Today's Challenge (0) | 2023.01.03 |
| Today's Challenge (0) | 2023.01.02 |
| Today's Challenge (0) | 2023.01.01 |
Comments