Skip to content

Commit 7564c5c

Browse files
committed
Time: 537 ms (97.88%), Space: 31.5 MB (18.18%) - LeetHub
1 parent 274444c commit 7564c5c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections import Counter
2+
from math import ceil
3+
from typing import List
4+
5+
6+
class Solution:
7+
def minOperations(self, nums: List[int]) -> int:
8+
dataSet = Counter(nums)
9+
sumOperations = 0
10+
for value in dataSet.values():
11+
if value == 1:
12+
return -1
13+
sumOperations += ceil(value / 3)
14+
return sumOperations
15+
16+
17+
nums = [2, 1, 2, 2, 3, 3]
18+
print(Solution().minOperations(nums))

0 commit comments

Comments
 (0)