A genome-style tape is a string s of lowercase letters. For a chosen letter c, scan every contiguous substring of exactly k characters and report the greatest number of times c appears inside any single such window.
Line 1: an integer k and a single lowercase letter c, separated by a space.
Line 2: the string s (lowercase English letters, no spaces).
A single integer: the maximum number of occurrences of c in any length-k substring of s.
s consists of lowercase English letters only.c is a single lowercase English letter.Example 1
Input
3 a abacaba
Expected
2
Explanation
The length-3 windows are aba, bac, aca, cab, aba; the most a's in any one of them is 2.
Example 2
Input
2 z hello
Expected
0
Explanation
The letter z never appears, so every window contains 0 of it and the answer is 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →