Standard Bar Sliding Window · Medium Problems O(n) · O(26)
A restorer inspects a long mural strip of colored tiles, each already painted one uppercase-coded color, and carries k cans of touch-up paint — each can repaints one tile into any color. The studio asks for the longest solid single-color band the restorer can produce. The painter evaluates a frame by asking one question: can the minority tiles inside it all be repainted within budget?
Input: A string s of uppercase English letters and an integer k, the repaint budget.
Output: Return the length of the longest single-letter substring achievable with at most k replacements.
1 <= s.length <= 10^5s consists of uppercase English letters0 <= k <= s.lengthInput: {"s":"ABAB","k":2}
Output: 4
Two repaints turn either letter into the other across the whole strip.
Input: {"s":"AABABBA","k":1}
Output: 4
The best band is "ABBA"-shaped: one repaint makes it four identical letters.