#C4168. Longest Substring Without Repeating Characters

    ID: 47676 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string \(s\), your task is to find the longest substring of \(s\) that contains no repeating characters. A substring is defined as a contiguous sequence of characters in the string.

If there are multiple substrings of the same maximum length, return the one which appears first.

Examples:

  • For \(s = \texttt{'abcabcbb'}\), the answer is \(\texttt{'abc'}\).
  • For \(s = \texttt{'bbbbb'}\), the answer is \(\texttt{'b'}\).
  • For \(s = \texttt{'pwwkew'}\), the answer is \(\texttt{'wke'}\).

inputFormat

The input consists of a single line containing a non-empty string \(s\). The string may contain letters, digits, and special characters.

outputFormat

Output the longest substring of \(s\) that does not have any repeating characters. The result should be printed in a single line.

## sample
abcabcbb
abc