LeetCode solutions

2362. Minimum Rounds to Complete All Tasks

My accepted Python solution to LeetCode problem 2362, Minimum Rounds to Complete All Tasks, running in 39ms.

  • Difficulty: Medium
  • Python
  • Runtime 39ms
  • Memory 33MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 39ms, memory 33MB, accepted 2026-01-02.

python
class Solution:
    def minimumRounds(self, tasks: List[int]) -> int:
        from collections import Counter
        count = Counter(tasks)
        result = 0
        for freq in count.values():
            if freq == 1:
                return -1
            # Use as many 3s as possible
            result += (freq + 2) // 3
        return result

Source