#C13233. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string S, find the longest substring of S that does not contain any repeated characters. In case there are multiple substrings with the maximum length, return the one that appears first in S. This problem tests your ability to implement a sliding window approach and is a common string manipulation problem.
Note: The answer must be produced by reading input from stdin
and printing the result to stdout
. Any formula or mathematical notation in the explanation is formatted in LaTeX if applicable.
For example, if S is "abcabcbb", the longest unique substring is "abc".
inputFormat
The input consists of a single line containing the string S. The string may include printable ASCII characters and its length can range from 0 to 105.
Input is provided via stdin
.
outputFormat
Output the longest substring that does not contain any repeating characters. In the case of multiple answers, output the substring that appears first in S.
The answer should be written to stdout
.
abcabcbb
abc