Help with this problem

Can you please tell how should I think this problem through?

@Doctor_Insult You are given a string of only 2 letters now you are allowed to change at most k letters, you need to now find the length of largest subarray that will have all same letters.
eg aabababaabaa k=2
now if we make the string aababaaaaaaa , aaaaaaa has all characters same (after making the maximum allowed changes)with length 7, so answer is 7

through iteration, how will we choose which characters to change?

@Doctor_Insult Use a kind of sliding window technique, keep maintaining the frequency of both char from start till this point, if the min freq is less than k we move forward and increase the answer else, we move our starting position and reduce the frequency of char at that position.


Here is a C++ Code for reference.
If this resolves your doubt mark it as resolved.