Chandler and the Boss

1

1 votes
Problem

Chandler is given a task by his boss. He is given a string S of length N which only has  ‘x’ & ‘y’. He can change the maximum of C alphabets in the given string. Finally, He has to tell his boss the  maximum length of a substring consisting of numofchar(x) == numofchar(y). In a single change he can change 'x'to'y' or 'y' to 'x'.

Since he wants to go out with his F.R.I.E.N.D.S. Can you tell him the answer?

Constraints

  • 1<=T<=100
  • 1 <= N <= 5*10^4
  • 0 <= C<= N

Input Format :

First line contains number of testcases T.

First line of each testcase contains two numbers N and C,length and maximum replacable characters.

Second line of each testcase contains string S.

 

Output Format:

Print the single interger per testcases denoting maximum length of substring.  

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

He can change 5th character to y and then substring from index 2 to index 7 will be of length 6 containing the equal number of x and y character. (considering 1 based indexing)

Editor Image

?