from collections import Counter
class Solution:
def minDeletions(self, s: str) -> int:
result = 0
used: set[int] = set()
for c in Counter(s).values():
while c and c in used:
result += 1
c -= 1
used.add(c)
return result
1647. Minimum Deletions to Make Character Frequencies Unique - LeetCode
ยท One min read