#K14106. Unique Substrings Counter
Unique Substrings Counter
Unique Substrings Counter
You are given a string S
and an integer K
. Your task is to count the number of unique substrings of length \(K\) in S
. A substring is a contiguous sequence of characters extracted from S
. If \(K\) is greater than the length of S
, then the answer is 0.
For example, if S = "abacab"
and K = 3
, the unique substrings are "aba", "bac", "aca", and "cab", so the output is 4.
Read the input from standard input (stdin) and output the answer for each test case on a new line to standard output (stdout).
inputFormat
The first line of input contains an integer T
, the number of test cases. Each of the next T
lines contains a string S
and an integer K
separated by a space.
outputFormat
For each test case, output a single line containing the number of unique substrings of length K
in the string S
.## sample
2
abacab 3
abcdef 2
4
5
</p>