ASAPUtils Logo ASAPUtils
Week 2

Longest Repeating Character Replacement

Longest Repeating Character Replacement with a sliding window where validity is arithmetic, with C++ and JavaScript solutions, a visualizer, and an explanation of why maxFreq never needs to be decreased.

The problem

Given a string and an integer k, you may change at most k characters to any other uppercase letter. Return the length of the longest substring containing a single repeated letter that you can produce.

s = "AABABBA", k = 1 -> 4 (change one B to get "AABA" -> "AAAA")

Related Problems