You are given a string word made of lowercase English letters. Your task is to check whether it is possible to remove exactly one character from the string so that every distinct letter that remains appears the same number of times.
A letter’s frequency means how many times it occurs in the string.
You must remove one character—doing nothing is not allowed.
Return true if removing one character can make all letter frequencies equal, otherwise return false.
Input: word = "ddcccb"
Output: false
Explanation:
Removing one 'c' gives "ddccb" → frequencies: d → 2 c → 2 b → 1 Still not equal. But removing 'b' gives "ddccc" → d → 2 c → 3 Still not equal. Removing one 'd' gives "dcccb" → d → 1 c → 3 b → 1 Not equal. Removing one 'c' gives "dcccb" → same as above. 👉 No removal produces equal frequencies.
Input: word = "ppqqr"
Output: true
Explanation:
Remove 'r' → "ppqq" Both p and q have frequency 2. All remaining letters have equal counts.
Accepted:
Submission: