CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsSliding Window

Longest Substring Without Repeating Characters

Medium
LeetCode
2/6
MediumSliding WindowLeetCode #3

Variable window + last-seen index

Expand right; if duplicate inside window, move left past previous occurrence.

Examples

Example 1

Input

abcabcbb

Output

3
Example 2

Input

bbbbb

Output

1

Stuck? Take a nudge

C++17Autosaves