Problems > Longest Substring Without Repeats

Longest Substring Without Repeats

Difficulty: 1400 2000 ms 128 MB

strings two-pointers

Find the length of the longest substring of S in which no character appears twice.

Input: one line with the string S.

Output: the maximum length of a repeat-free substring.

Constraints:

  • 1 ≤ |S| ≤ 104
  • S contains lowercase English letters

Sample Tests

Input 1
abcabcbb
Output 1
3
Input 2
bbbb
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.