Problem
FAANG · LeetCode #3

Longest Substring Without Repeating Characters — three-stage drill

1The ProblemMedium

Longest Substring Without Repeating Characters

Length of the longest substring with no repeated character.

length of the longest substring with all-unique charactersa0b1c2d3c4e5"abcd" — longest unique run, length 4return4
Examples
"abcdce"→ 4"pwwkew"→ 3
2The PatternTIME O(n) · SPACE O(k)

Sliding Window

A contiguous window that grows and shrinks to stay valid.

expand right · shrink left to keep the window valida0b1c2d3e4f5l = r›
Problems using this pattern
3The SolutionRESULT → 4

Step through it

↩ ANSWERlongest =1a0b1c2d3c4e5l = r›seen = {a← just added}
right → 0: add "a". window "a", best = 1
Step 1 / 9
Arrow keys to navigate · escape to reset

All problems by pattern

Backtracking

Recursive Descent