#C10427. Count Distinct Substrings
Count Distinct Substrings
Count Distinct Substrings
Given an integer \(k\) and a string \(s\), count the number of distinct substrings of length \(k\) in \(s\). A substring is a contiguous sequence of characters from the string. If \(k\) is greater than the length of \(s\), then output 0.
For example, if \(k = 3\) and \(s = "ababc"\), the distinct substrings of length 3 are "aba", "bab", and "abc", so the answer is 3.
inputFormat
The input consists of two lines:
- The first line contains an integer \(k\), which is the length of the substring.
- The second line contains the string \(s\).
outputFormat
Output a single integer representing the number of distinct substrings of length \(k\) in the given string \(s\).
## sample3
ababc
3