문제
풀이
슬라이딩 윈도우 풀이
class Solution:
def characterReplacement(self, s, k):
max_freq = res = 0
count = collections.Counter()
left = right = 0
while right < len(s):
count[s[right]] += 1
max_freq = max(max_freq, count[s[right]])
if res < max_freq + k:
res += 1
else:
count[s[right - res]] -= 1
left += 1
right += 1
return res