The Blind 75 Leetcode Series: Longest Repeating Character Replacement
Today, we are working on 424. Longest Repeating Character Replacement
You are given a string
s
and an integerk
. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at mostk
times.Return the length of the longest substring containing the same letter you can get after performing the above operations.
In this problem, we are given a string and an int. The string has a variety of 26 uppercase english letters. k
denotes number of times we can switch the letter in order to get the longest substring of the same letter.
It doesn’t specify which letter we are keeping or switching. We just need to keep track of number of letters we have switched.
Before moving on, we need to clarify some things:
- how long can the string be?
- can
k
be larger than the length of the string? - and we can double check on the uppercase english letter criteria