#C563. Longest Substring Without Repeating Characters

    ID: 49300 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string \( S \), your task is to find the length of the longest substring that contains no repeated characters. In other words, determine the maximum \( L \) such that there exists a contiguous substring of \( S \) of length \( L \) in which every character is distinct.

Example:

  • If \( S = \texttt{abcabcbb} \), then the longest substring is \( \texttt{abc} \) with length 3.
  • If \( S = \texttt{bbbbb} \), then the longest substring is \( \texttt{b} \) with length 1.

You are required to read the input from stdin and output the result to stdout.

inputFormat

The input consists of a single line containing the string \( S \). The string may include spaces or any visible characters.

Note: If the input is empty, then \( S \) is an empty string.

outputFormat

Output a single integer representing the length of the longest substring that contains only distinct characters.

## sample
abcabcbb
3