In Capital One's Eno chat experience, repeated characters can indicate noisy input. Given a string s, write a function that returns the length of the longest substring that contains no repeated characters.
A substring must be contiguous. Your solution should run efficiently for large inputs.
sExample 1
Input: s = "abcabcbb"
Output: 3
Explanation: The longest substring without repeating characters is "abc", which has length 3.
Example 2
Input: s = "bbbbb"
Output: 1
Explanation: Every substring longer than length 1 repeats the character b, so the answer is 1.
Example 3
Input: s = "pwwkew"
Output: 3
Explanation: One valid longest substring is "wke". "pwke" is not valid because it is not contiguous.
0 <= len(s) <= 10^5s contains printable ASCII characters