#K84507. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
You are given a string S
. Your task is to determine the length of the longest substring of S
that contains no repeating characters. In other words, find the maximum length of a contiguous segment of characters where every character is unique.
For example, if S = "abcabcbb"
, the longest substring without repeating characters is "abc"
which has a length of 3.
Note: If the string is empty, the answer should be 0.
You may assume that S
consists of ASCII characters.
Mathematically, you need to compute:
\[ \max_{0 \leq i \leq j \leq |S|} \{ j-i \;:\; \forall k, l \in [i, j), \; S_k \neq S_l \text{ for } k \neq l \} \]
inputFormat
The input consists of a single string S
provided through standard input (stdin). The string can contain letters, digits, and other ASCII symbols. It is guaranteed that the input does not contain leading or trailing spaces.
outputFormat
Output a single integer to standard output (stdout), which represents the length of the longest substring of S
with all unique characters.
abcabcbb
3