Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Distinct Echo Substrings

XPChallenge Points: 30
levelLevel: Hard

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.

Example 1:

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.

Example 2:

Input: text = "xyxyxy"

Output: 3

Explanation:

Valid echo substrings: "xyxy" "yxyx" "xyxyxy" All are formed by doubling a smaller string.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result