Since the maxRepeatLetterCount is global, why not just return maxRepeatLetterCount + k?
4 Likes
Doest work in this case :
“AABABBA” , 1
Output - 5
Expected - 4
I tried your example in the code, the output is also 4, which is correct. (maxRepeatLetterCount = 3 in this case and k = 1, return 4).
It may work in some test cases, but the problems requires a continuous subarray, some of them may not be continuous.
For example, “AABABBAA”, 1
Output - 6
Expected - 4