标签:char code err public character result solution ace pre
class Solution { public int characterReplacement(String s, int k) { int left =0,right=0; int maxLength = -1; int result = 0; char[] charNums = new char[256]; while (right<s.length()) { char cur = s.charAt(right); charNums[cur]++; maxLength = Math.max(maxLength, charNums[cur]); while ((right-left + 1 - maxLength) > k) { charNums[s.charAt(left++)]--; } result = Math.max(result, right - left + 1); right++; } return result; } }
标签:char code err public character result solution ace pre
原文地址:https://www.cnblogs.com/juniorMa/p/14545203.html