Here is the implementation:
function characterReplacement(s, k):
count = array of 26 zeros
maxFreq = 0
left = 0
result = 0
for right from 0 to s.length - 1:
count[s[right]] += 1
maxFreq = max(maxFreq, count[s[right]])
while (right - left + 1) - maxFreq > k:
count[s[left]] -= 1
left += 1
result = max(result, right - left + 1)
return result
time, space for the count array.