Longest Substring Without Repeating Characters
Return the length of the longest substring that contains no repeated characters.
A way to picture it
A caterpillar crawls along the string. Its head eats one letter at a time, and its body must never hold the same letter twice. When the head bites a letter already inside the body, the tail scoots forward just past the old copy.
How to approach it
Keep a window [L, R] with no repeats and remember where each letter was last seen. On a repeat inside the window, jump L to one past that last position.
Example
Input: {"s":"abcabcbb"}. Output: 3.
Complexity: O(n) time and O(k) space. Each pointer only moves forward; k is the alphabet size.
This page includes an animated walkthrough, Java and Python solutions, and a question to check your understanding.