Longest substring without repeating characters
Problem Given a string, find the length of the longest contiguous substring that contains no repeated character.
Input / Output
- Input: a string s.
- Output: the length of the longest substring without repeating characters.
Constraints
- Aim for O(n) time.
- s may contain any characters (letters, digits, symbols); the empty string returns 0.
Example
- "abcabcbb" -> 3 ("abc")
- "bbbbb" -> 1 ("b")
- "pwwkew" -> 3 ("wke")
asked …