#K14221. Longest Unique Substring

    ID: 24087 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

This problem requires you to determine the length of the longest substring of a given string that does not contain any repeating characters. In other words, you need to find the maximum length of a continuous segment of characters, such that every character in that segment is unique.

The problem can be solved efficiently using the sliding window technique. A detailed explanation is given by the formula below:

\( \text{max\_len} = \max_{0 \leq i \leq j < n} \{ j - i + 1 \ \vert \ s[i..j] \text{ contains all unique characters} \} \)

For example, for the input string "abcabcbb", the longest substring without repeated characters is "abc", with a length of 3.

inputFormat

The input consists of a single line containing a string \( s \), which may include spaces.

Note: The input should be read from standard input (stdin).

outputFormat

Output a single integer representing the length of the longest substring of \( s \) that contains no repeated characters. The output should be printed to standard output (stdout).

## sample
abcabcbb
3