Remove Letter to Equalize Frequency
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Bloomberg reported this one in December 2024, and it looks like a string problem but it's really a frequency-of-frequencies check. Count each letter, then ask whether one decrement makes all the counts match. If your OA invite is sitting in your inbox, this is a good one to see coming. The input is tiny in alphabet terms, only 26 letters, so brute force is allowed. StealthCoder is the quiet backup on the live OA if your mind goes blank mid-edge-case, but the idea here is simple enough to hold in your head.
The problem
Return whether deleting exactly one character occurrence from lowercase string word can make every remaining character have the same positive frequency. Function equalFrequency(word: String) → boolean Examples Example 1 word = "abcc" return = true Remove one c, leaving every character once. Example 2 word = "aazz" return = false One deletion leaves frequencies 1 and 2. Constraints 2 <= word.length <= 10^5. word contains lowercase English letters.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: the alphabet is capped at 26, so you can simulate. For each letter present, decrement its count, check whether all remaining nonzero counts are equal, then restore it. That's at most 26 checks of 26 values, effectively O(n) for the counting pass. The pitfall is the word 'positive'. If a letter drops to zero, it must be ignored, not treated as a frequency of 0. Watch the cases like 'aa' where removing one leaves a single 'a' with frequency 1, which is true. Also 'ab' is true, since removing one leaves one letter. And 'abc' with all counts 1 is true, because deleting one letter leaves the others equal. Don't forget that exactly one deletion is required, so already-equal strings like 'aabb' return false. If you freeze on these cases during the live OA, StealthCoder is the hedge that hands you the simulation approach fast.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Remove Letter to Equalize Frequency cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as remove letter to equalize frequency. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Remove Letter to Equalize Frequency FAQ
What's the trick to Remove Letter to Equalize Frequency?+
Count letter frequencies, then try decrementing each present letter once. After each decrement, collect the nonzero counts and check they're all the same. Restore the count and move on. With only 26 letters, this simulation is cheap and avoids messy case analysis.
How hard is this problem really?+
It's easy on paper but it punishes sloppy edge cases. The logic is short. Most failures come from forgetting that a count of zero should be ignored, or from assuming an already-balanced string is automatically true when exactly one deletion is required.
What's the time complexity?+
Counting is O(n) over the string. The simulation tries at most 26 letters and checks at most 26 counts each, so that's a constant 676 operations at worst. Overall it's O(n) time and O(1) extra space, which easily handles length 10^5.
Which edge cases should I test before submitting?+
Test 'abcc' (true), 'aazz' (false), 'aa' (true, leaves one letter), 'ab' (true), and 'aabb' (false, since one deletion unbalances it). Also try one letter with a count of 1 and others higher, like 'abbcc', which is true after removing the lone letter.
Is this pattern still asked in 2024 OAs?+
Yes, Bloomberg was reported with it in December 2024. Frequency counting with a hash table or array shows up constantly in string questions. Practice reducing a problem to counts, then checking a property on those counts. That skill transfers to many similar prompts.