LeetCode solutions

2532. Remove Letter To Equalize Frequency

My accepted Python solution to LeetCode problem 2532, Remove Letter To Equalize Frequency, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 16.9MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 16.9MB, accepted 2026-01-01.

python
class Solution:
    def equalFrequency(self, word: str) -> bool:
        from collections import Counter
        count = Counter(word)
        for c in word:
            count[c] -= 1
            if count[c] == 0:
                del count[c]
            if len(set(count.values())) <= 1:
                return True
            count[c] = count.get(c, 0) + 1
        return False

Source