#1316

Distinct Echo Substrings

candidate master · 1390 · lc hard +32 · verified · 53% accepted · 337 likes · top 44%

Description

Count the number of distinct non-empty substrings of text that consist of some string a concatenated with itself (i.e., substrings that can be written as a + a).

Example 1:

Input: text = "abcabcabc"
Output: 3
Explanation: The 3 substrings are "abcabc", "bcabca" and "cabcab".

Example 2:

Input: text = "leetcodeleetcode"
Output: 2
Explanation: The 2 substrings are "ee" and "leetcodeleetcode".

Code

1
2
3