← 返回 bytedance 的题目列表Longest Repeating Character Replacement
类型:online_judge
You are given a string s that consists of only uppercase English letters. You can replace any of the characters in the string with any other letter. You can perform this replacement at most k times.
Return the length of the longest substring containing the same letter you can get after performing the above operation at most k times.
Input:
A string s with length [1, 10^5].
An integer k with the possible range [0, |s|].
Output:
The maximum length of a substring with the same letter.
Example 1:
Input: s = "ABAB", k = 2
Output: 4
Write the code to achieve this functionality.
Example
Input
ABAB
2