This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public int characterReplacement(String s, int k) { | |
int windowStart = 0; | |
int[] frequenciesInCurrentWindow = new int['A' + 26]; | |
int maxFrequencyOfDominantCharacterSoFar = 0; | |
int kMinus1 = k - 1; | |
for (int windowEnd = 0; windowEnd < s.length(); windowEnd++) { | |
char rightChar = s.charAt(windowEnd); | |
int rightCharFrequency = ++frequenciesInCurrentWindow[rightChar]; |