dsa · medium
Longest Repeating Character Replacement
You may replace at most k characters of s. Return the length of the longest substring that can be made of **one** repeating character after those replacements.
Arguments
s— uppercase string to editk— maximum replacements allowed
Example
s = "ABAB", k = 2 → 4 (replace both As or both Bs).
s = "AABABBA", k = 1 → 4 (for example AABA by replacing the B).
Constraints
1 <= s.length <= 10^5 0 <= k <= s.length s consists of uppercase English letters Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: "ABAB" 2 Expected: 4
Example 2
Input: "AABABBA" 1 Expected: 4