题目
https://leetcode-cn.com/problems/longest-repeating-character-replacement/
分析
代码
class Solution {
public int characterReplacement(String s, int k) {
int len=s.length();
int[] nums=new int[26];
int left=0,right=0;
int max=0;
while(right<len){
nums[s.charAt(right)-'A']++;
max=Math.max(max,nums[s.charAt(right)-'A']);
if(right-left+1-max>k){
nums[s.charAt(left)-'A']--;
left++;
}
right++;
}
return right-left;
}
}