Length of the longest substring
intermediateFinds the longest substring with no repeating characters using a sliding window and hash set; O(n).
PhaseInit
Window—
MaxLen0
L0
R—
a
[0]b
[1]c
[2]a
[3]b
[4]c
[5]b
[6]b
[7]Window chars
Unvisited character
Best window (complete)
Duplicate / being removed
Left behind (past window)
Input: "abcabcbb" (lowercased). L=0, R=-1. Sliding window starts empty — expand R to grow the window.
1 / 22