#K96137. Count Distinct Characters in Fixed-length Substrings
Count Distinct Characters in Fixed-length Substrings
Count Distinct Characters in Fixed-length Substrings
You are given a string s and an integer n.
Your task is to determine the number of distinct characters in every substring of s that has a fixed length n. Specifically, if n > |s| (where \(|s|\) represents the length of the string), you should output -1. Otherwise, for each substring of length n, output the count of distinct characters.
For example, if \(s = \texttt{abcabc}\) and \(n = 3\), the substrings of length 3 are "abc", "bca", "cab", and "abc". Each of these substrings has 3 distinct characters, so the output is 3 3 3 3
.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains the string s.
- The second line contains the integer n.
outputFormat
If n > |s|, print -1
. Otherwise, print a sequence of integers, where each integer represents the number of distinct characters in the corresponding substring of length n. The integers should be separated by a single space and printed on a single line.
abcabc
3
3 3 3 3