#C2220. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s, find the longest substring of s that contains no repeated characters. If multiple substrings of the same maximum length exist, return the one that appears first in s.
The problem can be formalized as follows: Let \( s \) be a string, and a substring \( s[i \ldots j] \) (with \(0 \leq i \leq j < |s|\)) is valid if all characters in it are distinct. Find the valid substring with the maximum length. If there is a tie, choose the substring that occurs first.
For example:
- Input: "abcabcbb"; Output: "abc"
- Input: "pwwkew"; Output: "wke"
Your task is to implement a program that reads a string from standard input and writes the longest substring without repeating characters to standard output.
inputFormat
The input consists of a single line containing a string \( s \) (which may be empty). The string contains only ASCII characters.
outputFormat
Output the longest substring of \( s \) that contains no repeating characters. If there are multiple valid substrings, output the one that appears first.
## sampleabcabcbb
abc