Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1001 Bytes

_2423. Remove Letter To Equalize Frequency.md

File metadata and controls

42 lines (29 loc) · 1001 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 17, 2024

Last updated : June 17, 2024


Related Topics : Hash Table, String, Counting

Acceptance Rate : 17.49 %


Solutions

Python

class Solution:
    def equalFrequency(self, word: str) -> bool:
        letters = [0] * 26

        for c in word :
            letters[ord(c) - ord('a')] += 1

        for i in range(26) :
            letters[i] -= 1
            if all((x == max(letters)) or (x == 0) for x in letters) :
                return True
            letters[i] += 1

        return False