Given a string str of length n. The problem is to find the length of the longest sub-string in str having frequency of each character less than equal to the given value k.
INPUT : he first line consists of an integer T i.e. the number of test cases. First line of each test case consists of an integer k. The second and last line of each test case consists of an string s.
OUTPUT : Print the length of the longest substring with frequency of each character is less than k.
1<=k,|Length of string|<=105
Input : str = "babcaag", k = 1 Output : 3 abc and bca are the two longest sub-strings having frequency of each character in them less than equal to '1'. Input : str = "geeksforgeeks", k = 2 Output : 10
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.