Longest Repeating Character Replacement

Try to solve the Longest Repeating Character Replacement problem.


Given a string s and an integer k, find the length of the longest substring in s, where all characters are identical, after replacing, at most, k characters with any other lowercase English character.


  • 11 \leq s.length 103\leq 10^3
  • s consists of only lowercase English characters
  • 00 \leq k \leq s.length


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy