Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 82416fa

Browse files
committed
[20230104] solve medium problem
1 parent 2f2dcb6 commit 82416fa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# 2244. Minimum Rounds to Complete All Tasks
2+
# https://leetcode.com/problems/minimum-rounds-to-complete-all-tasks/
3+
4+
from typing import List
5+
from collections import Counter
6+
7+
8+
class Solution:
9+
def minimumRounds(self, tasks: List[int]) -> int:
10+
t = Counter(tasks)
11+
res = 0
12+
for _, count in t.items():
13+
if count == 1:
14+
return -1
15+
if count % 3 == 0:
16+
res += count // 3
17+
else:
18+
res += count // 3 + 1
19+
return res
20+
21+
22+
if __name__ == '__main__':
23+
sol = Solution()
24+
print(sol.minimumRounds([1 for _ in range(16)]))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /