#C2325. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string S, find the longest substring that contains only unique characters; that is, no character appears more than once in the substring. Formally, if the substring spans indices i to j of S, then for every k and l such that i \le k, l \le j and k \neq l, it must hold that S[k] \neq S[l]. In other words, if we denote a substring by \( S[i:j] \), then for all indices \( k, l \) where \( i \le k < l \le j \), we require:
[ \forall, i \leq k < l \leq j,\quad S[k] \neq S[l] ]
Your task is to implement an efficient solution that reads a single string from standard input and outputs its longest substring with all unique characters. If there are multiple substrings with the maximal length, output the one that appears first.
inputFormat
The input consists of a single line containing a string S
(possibly empty). The string may contain spaces or non-ASCII characters.
outputFormat
Output the longest substring of S
that contains only unique characters. The result should be printed to standard output.
abcabcbb
abc