Longest Repeating Character Replacement

Medium

You may change at most k characters of s to any uppercase letter. Return the length of the longest substring of a single repeated letter you can produce.

Example 1

characterReplacement()
Input
s = "ABAB", k = 2
Output
4

Example 2

characterReplacement()
Input
s = "AABABBA", k = 1
Output
4
Constraints
1 <= s.length <= 10^5
0 <= k <= s.length
`s` consists of uppercase English letters.

Topics

StringsSliding WindowHash Table

Implement characterReplacement in the editor and return the answer — printing it is never graded.