Longest Substring Without Repeating Characters
Given a string s, find the length of the longest contiguous substring that contains no repeated characters.
A substring is a contiguous sequence of characters within s. The answer must be the length of the longest such substring where every character appears at most once. Two characters repeat each other exactly when their code points are equal; case matters, so a and A are different characters.
Examples
Input: "abcabcbb"
Output: 3
Input: ""
Output: 0
Hints
What property does a substring have when all its characters are unique? Consider what happens as you extend it one character to the right.
When you encounter a character already inside the current window, the next candidate substring begins right after its previous occurrence. Where should you restart your search?
How can you tell whether a character already exists in the current window without scanning the entire window every time?
Longest Substring Without Repeating Characters
Given a string `s`, find the length of the longest contiguous substring that contains no repeated characters.