The algorithm only works when the set has a majority — more than half of the elements being the same. AAACCBB
in your example has no such majority. The most frequent letter occurs 3 times, the string length is 7.
The algorithm only works when the set has a majority — more than half of the elements being the same. AAACCBB
in your example has no such majority. The most frequent letter occurs 3 times, the string length is 7.