Skip to content

Commit da6e627

Browse files
Create 2870.py
1 parent fae08d0 commit da6e627

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

2501-3000/2870.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def minOperations(self, nums: List[int]) -> int:
3+
d = defaultdict(int)
4+
for num in nums:
5+
d[num] += 1
6+
7+
if min(d.values()) == 1:
8+
return -1
9+
10+
return sum(c // 3 + (c % 3 > 0) for c in d.values())
11+
12+

0 commit comments

Comments
 (0)