content: class Solution {
      public int characterReplacement(String s, int k) {
          int start = 0;
          int[] frequencyMap = new int[26];
          int maxFrequency = 0;
          int longestSubstringLength = 0;
  
          for (int end = 0; end < s.length(); end += 1) {
              // if 'A' is 0, then what is the relative order
              // or offset of the current character entering the window
              // 0 is 'A', 1 is 'B' and so on
              int currentChar = s.charAt(end) - 'A';
  
              frequencyMap[currentChar] += 1;
  
              // the maximum frequency we have seen in any window yet
              maxFrequency = Math.max(maxFrequency, frequencyMap[currentChar]);
  
              // move the start pointer towards right if the current
              // window is invalid
              Boolean isValid = (end + 1 - start - maxFrequency <= k);
              if (!isValid) {
                  // offset of the character moving out of the window
                  int outgoingChar = s.charAt(start) - 'A';
  
                  // decrease its frequency
                  frequencyMap[outgoingChar] -= 1;
  
                  // move the start pointer forward
                  start += 1;
              }
  
              // the window is valid at this point, note down the length
              // size of the window never decreases
              longestSubstringLength = end + 1 - start;
          }
  
          return longestSubstringLength;
      }
  }