274. Distinct Echo Substrings (Count)

HardStringString

Given a string s, return the number of distinct non-empty substrings that can be written as the concatenation of some string with itself (i.e., of the form a + a).

Input: A quoted string s.

Output: Integer — count of distinct echo substrings.

Examples

Example 1
Input: "abcabcabc"
Output: 3
Explanation: abcabc, bcabca, cabcab.
Example 2
Input: "leetcodeleetcode"
Output: 2
Explanation: ee and leetcodeleetcode.
Example 3
Input: "aaaa"
Output: 2
Explanation: aa and aaaa.

Constraints

Asked by

Google
Solve this problem in the editor →