Return the length of the longest substring of s in which every letter that appears occurs at least k times. Return 0 if there is none.
For s = "aaabb" and k = 3 the answer is 3 ("aaa"); for s = "ababbc" and k = 2 it is 5 ("ababb").
The starter code counts the letters of every substring. It is correct but too slow for long strings.
Example 1
Input:
longest_substring_k_repeating('aaabb', 3)
Output:
3
Example 2
Input:
longest_substring_k_repeating('ababbc', 2)
Output:
5
0 <= len(s) <= 1000001 <= k <= 100000No results yet
Run your code to check it against the examples, or submit to run every test.