Awesome java solution


  • 0
    F
        public int characterReplacement(String s, int k) {
            int[] count = new int[26];
            int maxCount = 0;
            int start = 0;
            int end = 0;
            while (end < s.length()) {
                maxCount = Math.max(maxCount, ++count[s.charAt(end) - 'A']);
                if (end - start + 1 - maxCount > k) {
                    --count[s.charAt(start++) - 'A'];
                }
                end++;
            }
            return end - start;
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.