How Many Distinct Substrings
Count the DISTINCT non-empty substrings of S.
Input: one line with the string S.
Output: the number of distinct substrings.
Constraints:
- 1 ≤ |S| ≤ 105
- lowercase letters
Sample Tests
Input 1
ababa
Output 1
9
Input 2
aaa
Output 2
3
Discussion (opens after you solve — no spoilers before)
No comments yet.