Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aca3683

Browse files
committedApr 8, 2025·
Do daily
1 parent a728bba commit aca3683

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎my-submissions/e3396.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def minimumOperations(self, nums: List[int]) -> int:
3+
cnt = Counter(nums)
4+
above = sum([1 for v in cnt.values() if v > 1])
5+
6+
for i, c in enumerate(nums) :
7+
if above == 0 :
8+
return ceil(i / 3)
9+
if cnt[c] == 1 :
10+
cnt.pop(c)
11+
cnt[c] -= 1
12+
if cnt[c] == 1 :
13+
above -= 1
14+
15+
return ceil(len(nums) / 3)

0 commit comments

Comments
 (0)
Please sign in to comment.