Longest Sub-string with at most K Distinct Characters
Posted: 11 Sep, 2020
You are given string S of length N, and an integer K. Your task is to find the length of the longest substring that contains at most K distinct characters.
The first line contains an Integer 'T' which denotes the number of test cases/queries to be run. Then the test cases follow. The first line of input for each test case/query contains an integer K. The second line of input for each test case/query contains a string S.
For each test case, print the length of the longest substring that contains at most K distinct characters. Output for every test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 10 1 <= K <= 26 1 <= N <= 10^4 Time Limit: 1sec
The Food Inspector
Posted: 31 Jul, 2022
Longest Palindromic Substring
Posted: 4 Sep, 2022
Posted: 10 Sep, 2022
Find The Single Element
Posted: 30 Oct, 2022
Posted: 24 Nov, 2022