medium

Longest Repeating Character Replacement

Given a string of uppercase letters and an integer k, you may change at most k characters. Return the length of the longest substring that can be made to consist of a single repeated letter.

Constraints
  • 1 ≤ s.length ≤ 10^5
  • Uppercase English letters only
  • 0 ≤ k ≤ s.length
Examples
in: s = "AABABBA", k = 1
out: 4
Change the middle A to get "BBBB".

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.