#K69832. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string S
, your task is to find the length of the longest contiguous substring in which every character is unique. In other words, you need to determine the maximum integer L such that there exists a substring S[i...j]
with all distinct characters, where
$$L = \max\{j - i + 1 \; : \; S[i...j] \text{ has all unique characters}\}$$
For example, if S = "abcabcbb"
, one of the longest substrings with unique characters is "abc", so the answer is 3
.
inputFormat
The input consists of a single line containing the string S
. Note that S
may include spaces and other printable ASCII characters.
outputFormat
Print a single integer representing the length of the longest substring of S
that contains only unique characters.
abcabcbb
3