Example 1
Input
s = "AABABBA", k = 1
Output
4
Replace one character to get "AABA" or "ABBA" where four characters become identical.
Full lesson preview
Given a string and an integer K, find the length of the longest substring achievable by replacing at most K characters so that all characters in the substring are the same.
Problem statement
Task
Examples
Input
s = "AABABBA", k = 1
Output
4
Replace one character to get "AABA" or "ABBA" where four characters become identical.
Input format
Output format
Constraints
Samples
Input
s = "AABABBA", k = 1
Output
4
We can replace one character to make a substring of length 4 with all same characters.