Loading content...
You are given a string consisting of lowercase English letters. Your task is to determine whether the string exhibits a balanced character distribution.
A string has a balanced character distribution if every distinct character that appears in the string occurs the exact same number of times as every other distinct character in the string.
In other words, if you count how many times each unique character appears, all these counts should be identical.
Return true if the string has a balanced character distribution, or false otherwise.
s = "abacbc"trueThe distinct characters are 'a', 'b', and 'c'. Character 'a' appears 2 times, 'b' appears 2 times, and 'c' appears 2 times. Since all characters occur exactly 2 times, the string has a balanced character distribution.
s = "aaabb"falseThe distinct characters are 'a' and 'b'. Character 'a' appears 3 times while 'b' appears only 2 times. Since the occurrence counts differ (3 ≠ 2), the string does not have a balanced character distribution.
s = "aaa"trueThere is only one distinct character 'a', which appears 3 times. With just a single character type, the frequency is trivially uniform, so the string has a balanced distribution.
Constraints