Skip to content
LC-2244 Medium LeetCode

2244. Minimum Rounds to Complete All Tasks

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 63% Topics: Array, Hash Table, Greedy, Counting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

import collections


# math, freq table
class Solution(object):
    def minimumRounds(self, tasks):
        """
        :type tasks: List[int]
        :rtype: int
        """
        cnt = collections.Counter(tasks)
        return sum((x+2)//3 for x in cnt.itervalues()) if 1 not in cnt.itervalues() else -1

Solution from kamyu104/LeetCode-Solutions · MIT