#2423
Remove Letter To Equalize Frequency
pupil · 595 · lc easy +29 · verified · 19.2% accepted · 794 likes · top 1%
Description
Given a string word of lowercase letters, determine whether removing exactly one character (at any position) causes all remaining characters to appear the same number of times.
Return true if this is possible, otherwise false.
Example 1:
Input: word = "abcc"
Output: true
Explanation: Select index 3 and delete it: word becomes "abc" and each character has a frequency of 1.
Example 2:
Input: word = "aazz"
Output: false
Explanation: We must delete a character, so either the frequency of "a" is 1 and the frequency of "z" is 2, or vice versa. It is impossible to make all present letters have equal frequency.
Code
1
2
3