Algorithm/Leetcode, Lintcode, HackerRank, etc.
2244. Minimum Rounds to Complete All Tasks
Roiei
2022. 5. 1. 14:55
반응형
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
반응형