Given a string S, find the length of the longest substring that contains no duplicate characters.
Input (stdin)
S
1 ≤ |S| ≤ 10^5S consists of ASCII printable characters.Output (stdout)
L
where L is the maximum length of a substring of S with all distinct characters.
Input
abcaefgh
Output
6
Explanation
The substring "bcaefg" (or "caefgh") has length 6 and contains no repeating characters.
Example 1
Input: abcaefgh
Output: 6
Longest distinct substring is "bcaefg" or "caefgh".
Example 2
Input: bbbb
Output: 1
Only one character can be taken because all are the same.
Constraints
Hints
Given a string S, find the length of the longest substring that contains no duplicate characters.
Input (stdin)
S
1 ≤ |S| ≤ 10^5S consists of ASCII printable characters.Output (stdout)
L
where L is the maximum length of a substring of S with all distinct characters.
Input
abcaefgh
Output
6
Explanation
The substring "bcaefg" (or "caefgh") has length 6 and contains no repeating characters.
Example 1
Input: abcaefgh
Output: 6
Longest distinct substring is "bcaefg" or "caefgh".
Example 2
Input: bbbb
Output: 1
Only one character can be taken because all are the same.
Constraints
Hints