#C4188. Count Unique Substrings
Count Unique Substrings
Count Unique Substrings
Given a string s and an integer k, your task is to count the number of unique substrings of length k present in s. A substring is defined as a contiguous segment of characters in the string. If the string length is less than k, output 0.
For example, if s = "ababc" and k = 2, the possible substrings are "ab", "ba", "ab", and "bc". The unique substrings are "ab", "ba", and "bc", so the output should be 3.
The mathematical formulation for this problem is: $$ ans = \begin{cases} 0, & \text{if } |s| < k \\ |\{ s[i:i+k] : 0 \leq i \leq |s|-k \}|, & \text{otherwise} \end{cases} $$
inputFormat
The input consists of two lines:
- The first line contains a string s (containing only lowercase letters).
- The second line contains an integer k, representing the length of the substring.
outputFormat
Output a single integer representing the number of unique substrings of length k in the string s.
## sampleababc
2
3