#C14690. Longest Unique Substring

    ID: 44367 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

Given a string s, find the length of the longest substring that does not contain any repeated characters. In other words, if we denote a substring of s by s[i...j] (where 0 \le i \le j < n and n is the length of s), you need to determine the maximum value of j - i + 1 such that every character in s[i...j] is unique. This problem can be solved efficiently using a sliding window technique.

Mathematically, if we denote the answer as \(L\), then \[ L = \max_{0 \le i \le j < n} \{ j - i + 1 \mid \text{all characters in } s[i\ldots j] \text{ are distinct} \} \]

Note: The input string may be empty. In that case, the answer is 0.

inputFormat

The input consists of a single line containing the string s.

Example: For input abcabcbb, the string is 'abcabcbb'.

outputFormat

Output a single integer representing the length of the longest substring of s that has no repeated characters.

## sample
0