#C13245. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string S, find the longest substring that consists of unique characters (i.e. no character repeats within the substring). If there are multiple substrings with the maximal length, return the one that appears first in S.
For example, given the input "abcabcbb", the longest substring with all distinct characters is "abc".
This problem can be solved efficiently using the sliding window technique with an auxiliary map to track the last positions of characters. See the formula for substring length update below:
$$\text{current_length} = i - \text{start} + 1$$
inputFormat
The input is provided from stdin and consists of a single line containing the string S. The string may include spaces and other printable characters.
outputFormat
Output the longest substring (from stdout) that is composed of unique characters. If there are multiple substrings with the same maximum length, output the first one encountered.
## sampleabcabcbb
abc