Longest Repeating Character Replacement - Implementation

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

O(n)O(n) time, O(26)=O(1)O(26) = O(1) space for the count array.