You may change at most k characters of s to any letters. Return the length of the longest substring that can be made of one repeated letter.
For s = "AABABBA" and k = 1 the answer is 4 (change one A or B to get "AAAA" or "BBBB" within a window).
The starter code counts the letters of every substring from scratch. It is correct but too slow for long strings.
Example 1
Input:
character_replacement('AABABBA', 1)
Output:
4
Example 2
Input:
character_replacement('ABAB', 2)
Output:
4
0 <= len(s) <= 2000000 <= k <= 200000s contains upper-case letters.No results yet
Run your code to check it against the examples, or submit to run every test.