โ† Core Algorithms
#5 most askedVery commonMediumSliding window

Longest Substring Without Repeating Characters

New to Sliding window? Learn it from scratch first
The Sliding Window Pattern โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Return the length of the longest substring of s with no repeated characters.

"abcabcbb" โ†’ 3 ("abc"), "bbbbb" โ†’ 1, "pwwkew" โ†’ 3 ("wke").

๐Ÿงช Practice

Write your solution, then press Run tests. Explain your approach out loud as you go.

Python
def length_of_longest(s):
    pass

Output appears here. Press Run or Ctrl/โŒ˜ + Enter.

Try it first. Struggling for a few minutes is how it sticks.