#C4596. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string ( s ), determine the length of the longest substring that contains no repeating characters. In other words, you must find the maximum length of a contiguous segment of the string ( s ) in which all characters are unique.
For example, if ( s = \texttt{abcabcbb} ), the answer is ( 3 ), because the longest substring without repeating characters is ( \texttt{abc} ).
Note: An optimal solution employs a sliding window technique running in ( O(n) ) time complexity.
inputFormat
A single line is provided as input which represents the string ( s ). The string can be empty.
outputFormat
Output a single integer representing the length of the longest substring of ( s ) that contains all distinct characters.## sample
abcabcbb
3