585. Longest Substring with Same Letters
0
Medium
Given a string s and an integer k, you have the option to change any character in the string to any other uppercase English character. You can perform this operation a maximum of k times. Find the length of the longest substring that can be obtained by performing these operations and contains only one type of letter.
Input Format
The first line contains the string s.
The second line contains the integer k.
Output Format
An integer representing the length of the longest substring.
Example
Input
ABAB
2
Output
4
Constraints
1 <= s.length <= 10^5
s consists of only uppercase English letters.
0 <= k <= s.length
Loading...
View Submissions
Console