Loading...
Given a string s and an integer k, you can choose any character and change it to any other uppercase English letter at most k times.
Return the length of the longest substring containing the same letter after performing at most k replacements.
AABABBA 1
4
AABABBA and the replacement limit k = 1.k replacements. The substring AABBB can be formed by replacing one A with a B, resulting in a substring of length 4 with the same letter B if we consider AABBB as BBBB after replacement, but since we are considering AABABBA we look at AABB and BBBA and see AABB can become AAAA or BBBB with one replacement.1$ replacement is of length $4$, which can be achieved by replacing one character in AABBto getAAAAor inBBBAto getBBBB`.