#C13480. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string s, find the longest substring that contains no repeated characters. A substring is a contiguous sequence of characters within the string. If there are multiple possible answers, return the substring that appears first.
The problem can be solved using the sliding window technique. This method uses two pointers to maintain a window of unique characters, and adjusts these pointers as you iterate through the string. The final answer is the longest such window found.
Formally, if we denote the input string as \( s \), your task is to find indices \( i \) and \( j \) (with \( 0 \leq i \leq j \leq |s| \)) such that the substring \( s[i:j] \) contains all distinct characters and \( j-i \) is maximized.
inputFormat
The input consists of a single line containing the string \( s \). The string can include letters, digits, and special characters.
outputFormat
Output the longest substring of \( s \) that contains no repeated characters. The output should be printed on a single line.
## sampleabcabcbb
abc