#K46362. Longest Unique Substring

    ID: 27960 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

Given a string S, find the length of the longest substring that contains only unique characters. In other words, determine the maximum window length L such that every character in the substring is distinct. Using a sliding window technique, you can solve this problem in O(n) time where n is the length of S. The formal definition is: $$L = \max_{\text{substrings } T \subset S} \{ |T| : \forall x,y \in T, x \neq y \text{ if } x \text{ and } y \text{ are positions in } T\}.$$

If S is an empty string, the result should be 0.

inputFormat

The input consists of a single line which contains the string S. The string may include letters, digits, or special characters.

outputFormat

Output a single integer which is the length of the longest substring with all unique characters.

## sample
abcabcbb
3