#3714
Longest Balanced Substring II
medium · 42% accepted · 555 likes · top 23%
hash table · string · prefix sum
Description
You are given a string s consisting only of the characters 'a', 'b', and 'c'.
A substring of s is called balanced if all distinct characters in the substring appear the same number of times.
Return the length of the longest balanced substring of s.
Solution