Longest Repeating Character Replacement
Given a string s of uppercase English letters and an integer k, you may replace at most k characters with any uppercase letter. Return the length of the longest substring containing a single repeated letter you can produce after those replacements.
Open official problem prompt ↗Find the longest window that can be turned into all-identical letters using no more than k replacements.
You have k blank tiles in a word game; the longest run you can make uniform is the run where only k tiles differ from its most common letter.
- Input
- s = "AABABBA", k = 1
- Output
- 4
- Why
- Replacing one character in "AABA" (or "ABBA") yields four identical letters, e.g. "AAAA".
1 <= s.length <= 10^5s consists of only uppercase English letters0 <= k <= s.length