FastPrepRemove Letter to Equalize Frequency

Remove Letter to Equalize Frequency

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREENONSITE INTERVIEW
Learn

Problem statement

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.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public boolean equalFrequency(String word) {
  // Write your code here.
}
word"abcc"
expectedtrue
Checking account…