String Manipulation

Longest Substring Without Repeats

mediumstringsliding-windowstring
0:00

Problem

Given a string `s`, return the length of the longest substring without repeating characters.

Your solution
Test results
Click Run tests to check your solution against the test cases.

About this challenge

Longest Substring Without Repeats is a medium string manipulation coding challenge. It tests string-manipulation techniques: parsing, transforming, and searching text efficiently. Write your solution in the editor above, run it against the test cases, and get instant feedback — free, in your browser, no sign-up.

Show a hint & approach (spoiler)

Hint: Sliding window with a Set. When you hit a duplicate, shrink from the left until the duplicate is gone.

Keep practicing

Browse all coding challenges, or build intuition for the underlying concepts with the algorithm visualizers and the developer cheatsheets.