Longest Substring Without Repeating Characters

MEDIUM-HARD · C · 3000ms

For a "typing test" feature, Meherun's tool must find the longest stretch of typed text with no character repeated. Read a string S. Print the length of the longest substring that has no repeated characters. Aim for O(N) using a sliding window, not O(N^2).

Input

One string S of lowercase letters.

Output

An integer: the length.

Constraints

1 ≤ |S| ≤ 10^5

Sample Input

abcabcbb

Sample Output

3
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Longest Substring Without Repeating Characters · DIU ContestHub