ASAPUtils Logo ASAPUtils
Week 2

Longest Substring Without Repeating Characters

The canonical variable sliding window, solved with a set in O(n), with C++ and JavaScript solutions, a visualizer, and the amortised argument for why the inner while loop is free.

The problem

Given a string, return the length of the longest contiguous substring that contains no repeated characters.

s = "abcabcbb" -> 3 (the substring "abc")

Related Problems