We’re preparing your current view and syncing the latest data.
Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string. In one operation, you can choose any character of the string and change it to any other uppercase English character. Find the length of the longest substring containing all repeating letters you can get after performing the above operations.
A string s and an integer k representing the maximum number of operations allowed.
An integer representing the length of the longest substring with all repeating letters after at most k character replacements.
1 <= s.length <= 10^5; 0 <= k <= s.length; s contains only uppercase English letters.
Example 1
Input
s = "ABAB", k = 2
Output
4
Explanation
Replace the two 'A's with 'B's or two 'B's with 'A's to make the string 'BBBB' or 'AAAA'. The longest substring length is 4.
Example 2
Input
s = "AABABBA", k = 1
Output
4
Explanation
Replace the one 'B' in the middle with an 'A' to get 'AABAABA', the longest repeating substring is 'AAAA' with length 4.