#3713

Longest Balanced Substring I

medium · 69.7% accepted · 415 likes · top 78%

hash table · string · counting · enumeration

Description

You are given a string s consisting of lowercase English letters.

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