Given a string s consisting of uppercase letters and an integer k, you may change up to k characters in the string to any other uppercase letter. Return the length of the longest substring containing a single repeated letter you can obtain after performing these changes.
s = "ABAB", k = 24s = "AABABBA", k = 14Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A window — a contiguous subarray or substring — expands and shrinks as it moves across the input, so you track a running condition instead of recomputing it from scratch for every possible window.
Read the full Sliding Window guide →
Original problem on LeetCode ↗