C语言 | Leetcode C语言题解之第424题替换后的最长重复字符
题目:
题解:
int characterReplacement(char* s, int k) {int num[26];memset(num, 0, sizeof(num));int n = strlen(s);int maxn = 0;int left = 0, right = 0;while (right < n) {num[s[right] - 'A']++;maxn = fmax(maxn, num[s[right] - 'A']);if (right - left + 1 - maxn > k) {num[s[left] - 'A']--;left++;}right++;}return right - left;
}