Skip to content

Commit 1177e36

Browse files
authored
Create minimum-rounds-to-complete-all-tasks.py
1 parent c0176bc commit 1177e36

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
import collections
5+
6+
7+
# math, freq table
8+
class Solution(object):
9+
def minimumRounds(self, tasks):
10+
"""
11+
:type tasks: List[int]
12+
:rtype: int
13+
"""
14+
cnt = collections.Counter(tasks)
15+
return sum((x+2)//3 for x in cnt.itervalues()) if 1 not in cnt.itervalues() else -1

0 commit comments

Comments
 (0)