Medium · Sliding window

Longest Repeating Character Replacement

You are given a string of capital letters, s, and a number, k. You may change at most k letters to any other capital letter. Return the length of the longest stretch of one repeated letter you can make.

  • The string is never empty.
  • k can be 0, which means no changes.
  • The stretch must be consecutive letters.
s = "AABABBA"
k = 1

→ 4   (AABA becomes AAAA)
Record your take

No one has solved it yet.