Problem Overview You’re given a string s (uppercase letters only) and an integer k. You can replace any character in the string up to k times. Return the length of the longest substring containing the same letter after performing those replacements. Brute Force Intuition The idea is straightforward — generate every possible substring, track the frequency of each character inside it, and check if the window is “valid.”
Try all possible substrings with two nested loops Track character frequency within the current substring Track maxFreq — the count of the most frequent character If len - maxFreq <= k, the window is valid — update the result How this works, we have the maxFreq of that substring if we subract it from the len then we got len of other chars. The string is only valid if the no of conversion we have to make is less than k that is length - maxFreq;
...