All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 17, 2024
Last updated : June 17, 2024
Related Topics : Hash Table, String, Counting
Acceptance Rate : 17.49 %
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