#K8221. Longest Non-Repeating Substring

    ID: 35925 Type: Default 1000ms 256MiB

Longest Non-Repeating Substring

Longest Non-Repeating Substring

Given a string s, your task is to determine the length of the longest substring that contains no repeating characters.

More formally, if we define a substring as a contiguous sequence of characters from s then you must find the maximum length l such that there exists a substring s[i...j] (with j - i + 1 = l) whose characters are all unique. In mathematical terms, if S is the set of characters in the substring, then |S| = l. This can also be expressed using the formula \( l = j - i + 1 \) where the substring meets the condition \( \forall k_1, k_2 \in [i, j], k_1 \neq k_2 \Rightarrow s[k_1] \neq s[k_2] \).

The input will be provided via standard input (stdin) and you should output the result to standard output (stdout).

inputFormat

The input consists of a single line containing a string s. The string may be empty and can contain any printable ASCII characters.

Input Format:

s

outputFormat

Output a single integer representing the length of the longest substring of s that does not contain any repeating characters.

Output Format:

result
## sample
abcabcbb
3