#C12275. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string s, your task is to compute the length of the longest substring containing only unique characters. In other words, find the maximum length segment of s in which no characters appear more than once.
For example, if s = "abcabcbb"
, then the longest substring with all unique characters is "abc" whose length is 3.
The problem can be formally defined as follows:
Given a string \( s \), determine the maximum integer \( L \) such that there exists a substring \( s[i \dots j] \) (with \( j - i + 1 = L \)) where all characters are distinct.
If the input string is empty, the answer is 0.
inputFormat
The input consists of a single line containing the string s. The string may include spaces and special characters. It can also be empty.
Input Format:
s
outputFormat
Output the length (an integer) of the longest substring of unique characters found in the input string.
Output Format:
L
where L is the answer.
## sampleabcabcbb
3