Count Distinct Substrings

Given a string *s*, determine the total number of distinct non-empty substrings of *s*. A substring is any contiguous block of characters. Two substrings are considered distinct if they occur at different positions or have different content.

Input Format

One line containing string s.

Output Format

An integer: the count of distinct substrings.

Constraints

  • len(s) <= 2000.

Examples

Example 1:

Input:

s = "aba"

Output:

5

Explanation:

Distinct substrings are: "a", "b", "ab", "ba", "aba".

Loading...
Count Distinct Substrings - Strings DSA Problem