2423. Remove Letter To Equalize Frequency

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2423

class Solution:
    def equalFrequency(self, word: str) -> bool:
        cnt = Counter(word)
        for c in cnt.keys():
            cnt[c] -= 1
            if len(set(v for v in cnt.values() if v)) == 1:
                return True
            cnt[c] += 1
        return False