← All problemsSign in

Substring of a Substring

CodeChefRating 1442Open on judge ↗

Shefin gives you a string $S$ and you have to find a non-empty string $P$ such that: - $P$ is a substring of $S$. - **No** non-empty substring of $P$ is a **prefix** of $S$. - **No** non-empty substring of $P$ is a **suffix** of $S$. For all such possible strings, find the length of the **longest** string satisfying all the conditions. If no such string is possible, print $-1$. A string $A$ i

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start