#C9667. Longest Substring Without Repeating Characters

    ID: 53785 Type: Default 1000ms 256MiB

Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Given a string s consisting only of lowercase English letters, your task is to find the length of the longest substring that does not contain any repeating characters.

A substring is defined as a contiguous sequence of characters within the string. Formally, if the string has length \(n\), you need to determine the maximum length \(L\) such that there exists some indices \(i\) and \(j\) with \(0 \leq i \leq j < n\) where all characters in s[i...j] are unique. That is, \(L = \max\{j-i+1 : s[i...j] \text{ has no duplicate characters}\}\).

For example, for the input "abcabcbb", the longest substring without repeating characters is "abc", which has a length of 3.

inputFormat

The input is provided via standard input (stdin) and consists of a single line containing the string s. The string s is composed solely of lowercase English letters.

Example:

abcabcbb

outputFormat

Output a single integer to standard output (stdout) corresponding to the length of the longest substring of s that has no repeating characters.

Example:

3
## sample
abcabcbb
3