LeetCode_424_替换后的最长字符串
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; } }