#K94682. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s, find the length of the longest substring that does not contain any repeating characters.
For example, if s = "abcabcbb"
, the longest substring without repeating characters is "abc", and its length is 3.
This problem requires you to traverse the string efficiently and determine the maximum length of any contiguous segment where all characters are unique. Formally, if the substring is denoted by s[i:j], then all characters s[i], s[i+1], \ldots, s[j-1] must be distinct, and you need to compute \(\max (j - i)\).
The input is read from the standard input and the output is printed to the standard output.
inputFormat
A single line containing the string s. Note that the string may include spaces and special characters.
outputFormat
Output a single integer – the length of the longest substring of s that contains no repeating characters.## sample
abcabcbb
3