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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 16.9MB, accepted 2026-01-01.
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