#K54562. Longest Substring Without Repeating Characters

    ID: 29781 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string s, your task is to find the length of the longest substring without repeating characters.

For a given string, a substring is a contiguous sequence of characters within the string. The substring should contain unique characters only. If the string is empty, the answer is 0.

The problem can be mathematically described as finding the maximum value of len(s[i:j]) such that for all k, l in the range [i, j) with k != l, s[k] != s[l]. In LaTeX, if we denote the substring as \( s[i:j] \), then we want to maximise \( j-i \) subject to \( s_k \neq s_l \) for \( i \le k < l < j \).

inputFormat

The input consists of a single line containing the string s. The string may contain spaces and any printable characters. An empty line represents an empty string.

outputFormat

Output the length of the longest substring of s that does not contain any repeated characters. Print the result as an integer on a single line.

## sample
abcabcbb
3

</p>