2244. Minimum Rounds to Complete All Tasks
2022. 5. 1. 14:55ㆍAlgorithm/Leetcode, Lintcode, HackerRank, etc.
- 목차
반응형
class Solution:
def minimumRounds(self, tasks: List[int]) -> int:
freq = collections.Counter(tasks)
cnt = 0
for num, count in freq.items():
if count < 2:
return -1
while count >= 2:
if (count > 2 and count % 2 != 0) or count % 3 == 0:
count -= 3
else:
count -= 2
cnt += 1
return cnt
반응형
'Algorithm > Leetcode, Lintcode, HackerRank, etc.' 카테고리의 다른 글
2410. Maximum Matching of Players With Trainers (0) | 2023.01.07 |
---|---|
2409. Count Days Spent Together (0) | 2023.01.07 |
2243. Calculate Digit Sum of a String (0) | 2022.04.29 |
2248. Intersection of Multiple Arrays (0) | 2022.04.29 |
2138. Divide a String Into Groups of Size k (0) | 2022.01.22 |