#C3836. Longest Unique Substring

    ID: 47307 Type: Default 1000ms 256MiB

Longest Unique Substring

Longest Unique Substring

Given a string s composed only of lowercase letters, your task is to determine the length of the longest substring that does not contain any repeated characters. In other words, find the maximum size of a contiguous segment of s where every character appears only once.

This problem can be formally defined as follows: Given a string \( s \) of length \( n \), find the maximum \( L \) such that there exists indices \( i \) and \( j \) with \( 0 \leq i \leq j < n \) where \( j - i + 1 = L \) and all characters in \( s[i\ldots j] \) are distinct.

If the string is empty, the result is 0.

inputFormat

The input consists of a single line containing a string s (possibly empty) of lowercase English letters.

outputFormat

Output a single integer representing the length of the longest substring of s that contains no repeated characters.

## sample
abcaefgb
6