All tasks
Hardtwo-pointershashstrings

Longest Substring Without Repeats

Time limit 2 s · Memory 64 MBAcceptance: 100.0%Solved by: 1

Statement

You are given a string of lowercase Latin letters. Print the length of the longest contiguous substring in which all characters are distinct.

Examples

Example 1
Input
abcabcbb
Output
3
Example 2
Input
bbbbb
Output
1

Constraints

  • String length is between 1 and 10^5
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.