text of lowercase English letters and a number min_count. Find the longest substring (a contiguous piece of text) in which every letter that appears does so at least min_count times.
Return its length, or 0 if there is no such substring.text='xxyzzyq', min_count=2 → 6
In "xxyzzy" every letter occurs exactly twice, while q appears only once and cannot be included. The answer is 6.
text='abab', min_count=3 → 0
No letter occurs three times, so no substring qualifies.
text='mmmn', min_count=1 → 4
With a threshold of 1 the whole string qualifies.
text.length ≤ 10⁴text consists of lowercase English lettersmin_count ≤ 10⁵text='xxyzzyq', min_count=2
6
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.