if (windowEnd - windowStart + 1 - maxRepeatLetterCount > k) {
char leftChar = str.charAt(windowStart);
letterFrequencyMap.put(leftChar, letterFrequencyMap.get(leftChar) - 1);
windowStart++;
}
the maxRepeatLetterCount
could be changed if “windowStart” is pointing the character which has maxRepeatLetterCount
. Then, windowStart increase 1, and maxRepeatLetterCount decrease 1, so this part of code need to be processed one more time. So I think using while
is correct and each time we need to calculate maxRepeatLetterCount
. Is there someone can explain this part? I’m very confused.