Description

Return the number of distinct non-empty substrings of s that can be written as the concatenation of some string with itself.

Examples

Input:text = "abcabcabc"
Output:3
Explanation:

abcabc, bcabca, cabcab.

Input:text = "a"
Output:0
Explanation:

Edge case with a single character.

Input:text = "aabaabaa"
Output:2
Explanation:

The 2 distinct echo substrings are "aabaab" (aab+aab) and "abaaba" (aba+aba).

Constraints

  • 1 ≤ text.length ≤ 2000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!