Back to course home
0% completed
Vote For New Content
Solution: Find Longest Self-Contained Substring
Problem Statement
Given a string s, find the length of the longest substring from s that meets these two rules:
- It should not be equal to the full string s.
- No letter inside this substring should appear anywhere else in s (outside the substring).
If there is no such substring, return -1.
Examples
Example 1
- Input: s=
"abcabcx"
- Output:
6
- Explanation:
The substring"abcabc"
is a valid self-contained substring of length6
.
The last character"x"
does not appear in"abcabc"
, and none of the characters from
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible