A substring is called an echo substring if it is formed by taking some string a and repeating it twice (i.e., it looks like a + a).
You are given a string text, and your task is to determine how many unique non-empty substrings of this type exist in the string.
A substring is considered distinct if its content is different from others, even if the same pattern appears multiple times at different locations.
Input: text = "aaaa"
Output: 2
Explanation:
Echo substrings are: "aa" (a + a) "aaaa" (aa + aa) Although "aa" appears more than once, it is counted once because we only count distinct substrings.
Input: text = "xyxyxy"
Output: 3
Explanation:
Valid echo substrings: "xyxy" "yxyx" "xyxyxy" All are formed by doubling a smaller string.
Accepted:
Submission: