#K69857. Unique Substrings Counter
Unique Substrings Counter
Unique Substrings Counter
Given a string s, compute the number of its unique substrings. A substring is defined as a contiguous sequence of characters from s. The problem requires you to count all distinct substrings of the input string.
For a string of length \(n\), any substring can be represented as \(s[i:j]\) for \(0 \le i < j \le n\). The answer is given by the size of the set of these substrings.
For example, consider \(s = \texttt{abab}\). Its distinct substrings are:
\(\{\texttt{a}, \texttt{b}, \texttt{ab}, \texttt{ba}, \texttt{aba}, \texttt{bab}, \texttt{abab}\}\), which gives a total of 7 unique substrings.
Input Constraints: The input string will have a small length so that an \(O(n^2)\) solution is acceptable.
inputFormat
The input consists of a single line containing the string s.
Example:
abab
outputFormat
Output a single integer representing the number of unique substrings of the input string.
Example:
7## sample
abab
7