Find the length of the longest substring that can be turned into a string of identical characters by replacing at most k characters.
You are given a string s consisting of uppercase English letters and an integer k.
In one move, you may choose any character in a substring and replace it with any other uppercase English letter.
Return the length of the longest substring that can be converted into a string where every character is the same after performing at most k replacements.
Find the maximum possible length of a contiguous substring that can be made uniform using no more than k changes.
s of uppercase English letters.k representing the maximum number of replacements allowed.1 <= s.length <= $10^{5}$0 <= k <= s.lengths contains only uppercase English letters A-Z.Example 1
Input
s = "ABAB", k = 2
Output
4
Explanation
Replace both A characters with B, or both B characters with A, so the whole string becomes uniform.
Example 2
Input
s = "AABABBA", k = 1
Output
4
Explanation
One optimal choice is the substring AABA. Replace one B with A to make it AAAA.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.