Maximum Sub-String after at most K changes
Submissions: 257   Accuracy:

15.95%

  Difficulty: Easy   Marks: 2

We have a string of length n, which consist only UPPER and LOWER CASE characters and we have a number k (always less than n and greater than 0). We can make at most k changes in our string such that we can get a sub-string of maximum length which have all same characters.

Input:
The first line of the input contains an integer T which denotes the number of test cases to follow. Each test case contains space separated 2 integers n and k. Next line has a string of length n. 

Output:
Print an integer which denotes the maximum length possible.

Constraints:
1<=T<=100
1<=n,k<=100000
1<=|S|<=100000​​

Example:
Input:

2
5 2
ABABA
6 4
HHHHHH

Output:
5
6

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shashwat Jain
Author: shashwat jain


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.