#C9686. Maximum Distinct Characters in a Substring
Maximum Distinct Characters in a Substring
Maximum Distinct Characters in a Substring
You are given a string s
consisting of lowercase English letters and an integer k
. Your task is to determine the maximum number of distinct characters present in any contiguous substring of s
with length k
.
We denote the string as \( s \) and the integer as \( k \). For each substring \( s[i:i+k] \) (where \( 0 \leq i \leq |s|-k \)), compute the number of distinct characters and output the maximum value found among all these substrings.
Example:
Input: abcda 3</p>Output: 3
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains the string \( s \) which consists only of lowercase English letters.
- The second line contains the integer \( k \), representing the length of the substring to consider.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of distinct characters found in any substring of length \( k \).
## sampleabcda
3
3