#C3064. Longest Unique Substring

    ID: 46450 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

Given a string s, your task is to find the longest substring that contains all unique characters. A substring is a contiguous sequence of characters within the string. The solution should use an efficient approach (for instance, a sliding window technique) to accomplish the task. Formally, if we denote the set of all characters in a substring S by \(\{ s_i \}\), then each character must satisfy \(s_i \neq s_j\) for any two positions \(i \neq j\). If there are multiple answers, return the substring that appears first.

Example:

  • Input: "abcabcbb"
  • Output: "abc"

inputFormat

The input is provided from standard input and consists of a single line containing the string s.

outputFormat

Output to standard output the longest substring of s that contains all unique characters.

## sample
abcabcbb
abc