#C12687. Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters
Given a string s
, your task is to compute the length of the longest substring that contains no repeated characters. In other words, you need to find the maximum length of any contiguous sequence of characters in s
in which each character appears only once.
For example, if s = "pwwkew"
, one of the longest substrings with all distinct characters is "wke", which has a length of 3. Your solution should be efficient enough to handle large inputs.
The solution must read input from standard input (stdin) and output the result to standard output (stdout). If the input string is empty, the output should be 0.
inputFormat
The input consists of a single line containing the string s
.
Note: The string may contain any printable characters. The input is provided via standard input (stdin).
outputFormat
Output a single integer which represents the length of the longest substring of s
that does not contain any duplicate characters. The output must be provided via standard output (stdout).
pwwkew
3