代码
int f(string s, int k) {
vector<int> num(26, 0);
int left = 0;
int right = 0;
int maxCharacterNum = 0;
while (right < s.length()) {
num[s[right] - ‘A‘]++;
maxCharacterNum = max(maxCharacterNum, num[s[right] - ‘A‘]);
if (right - left + 1 - maxCharacterNum > k) {
num[s[left++] - ‘A‘]--;
}
right++;
}
return right - left;
}
原文:https://www.cnblogs.com/wy1102808691/p/14364561.html