Return the length of the longest substring of s that has at most k different characters.
For s = "eceba" and k = 2 the answer is 3 ("ece").
The starter code tries every start. It is correct but too slow for long strings.
Example 1
Input:
longest_k_distinct('eceba', 2)
Output:
3
Example 2
Input:
longest_k_distinct('aa', 1)
Output:
2
0 <= len(s) <= 2000000 <= k <= 26s contains lower-case letters.No results yet
Run your code to check it against the examples, or submit to run every test.