Sliding WindowMedium

Longest Repeating Character Replacement

You may change up to k letters of s (uppercase A–Z) into any other letter. Return the length of the longest run of one repeated letter you can make.

Example 1s = "AABAB", k = 1 → 4Change the B in the middle: "AAAAB".
Example 2s = "ABCD", k = 0 → 1
1 ≤ length ≤ 10⁵ · 0 ≤ k ≤ length

Hints

0 of 3 open
Hint 2 · the patternHint 3 · the key line