|
||||||||||
SubstringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1702 Accepted Submission(s): 681 Problem Description You are given a string $S[1..N]$ containing only lowercase letters. Now you need to find the longest substring $S[l..r]$ such that every letter (`a` to `z`) appears no more than $K$ times in the substring. You just need to output the length ($r-l+1$) of the longest substring. Input There are multiple test cases. Each test case contains one integer $K$ ($1\leq K \leq N$) and one string $S$ in one line. It's guaranteed that the sum of lengths of the input strings is no more than $4 \times 10^5$. Output For each test case, print one integer in one line, denoting the length of the longest substring. Sample Input
Sample Output
Source | ||||||||||
|