Skip to content

Instantly share code, notes, and snippets.

View mikhail-putilov's full-sized avatar

Mikhail Putilov mikhail-putilov

  • Austria, Vienna
View GitHub Profile
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];