Back to DSA
Longest Substring Without Repeating Characters
mediumGiven a string, determine the length of its longest contiguous segment that contains no repeated characters. Every character in the segment must be distinct.
Examples
Example 1:
Input:
s = "xyzxyzaa"Output:
3Explanation: The segment 'xyz' has length 3 and contains all unique characters. No longer valid segment exists.
Example 2:
Input:
s = "qqqqq"Output:
1Explanation: Every character is identical, so the longest segment without repetition has length 1.
Hints
1234567