Distinct Echo Substrings

Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e., it can be written as a + a where a is some string).

Example 1
Inputtext = "abcabcabc"
Output3
The 3 substrings are "abcabc", "bcabca" and "cabcab".
Example 2
Inputtext = "leetcodeleetcode"
Output2
The 2 substrings are "ee" and "leetcodeleetcode".

Constraints

  • 1 <= text.length <= 2000
  • text has only lowercase English letters.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate