#C9990. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
You are given a string s
. Your task is to find the longest substring that contains only unique characters (i.e. no character is repeated).
If there are multiple substrings with the same maximum length, output the one that appears first.
Formally, if the input string is \( s \), find the substring \( s[i \ldots j] \) such that all characters in \( s[i \ldots j] \) are distinct and \( j - i + 1 \) is maximized. If multiple solutions exist, choose the one with the smallest i.
inputFormat
A single line of input containing the string ( s ). The string can be empty.
outputFormat
Output the longest substring of ( s ) that contains only unique characters. If there are multiple answers, output the first one found.## sample
abcabcbb
abc