일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Daily Challenge
- Problem Solving
- 리얼 클래스
- Writing
- 3줄정리
- realclass
- 미드시청
- 스탭퍼
- 링피트
- 만화도
- 운동
- 영어공부
- 개발자
- 읽기
- 10분
- leetcode
- 30분
- 월간
- FIT XR
- 사이드
- 괜찮음
- 영어원서읽기
- 쓰릴오브파이트
- 프로젝트
- English
- 뭐든
- 파비최
- 매일
- 잡생각
- 화상영어
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