Pattern Recognition Drill
Medium Sliding Window
The Problem
Given a string, find the length of the longest substring without repeating characters.
What approach would you use?
Think about it before scrolling down.
Expand right; when duplicate found, shrink left past the previous occurrence. O(n).
Map char → last index to jump left pointer directly instead of shrinking one by one.
Common Trap
Don't restart from scratch when a duplicate is found — just slide the left pointer forward.