← All problems
Longest Substring Without Repeating Characters
Length of the longest substring with all distinct characters.
Complexity
Time O(n), Space O(min(n, alphabet))
Common pitfalls
- Moving left to last_seen+1 without max() (moves backward)
- O(n^2) re-scanning
Your solution
Log in to save your code and track progress.