

A

In Providence messaging and note-entry surfaces, repeated characters can appear in free-text input. Write a function that returns the length of the longest substring in a string s that contains no repeated characters.
ss with all unique charactersA substring must be contiguous. The function should run efficiently for large inputs.
Example 1
s = "abcabcbb"3"abc", which has length 3.Example 2
s = "bbbbb"1"b", so the best answer is 1.Example 3
s = "pwwkew"3"wke" is a valid longest substring. "pwke" is not valid because it is not contiguous.0 <= len(s) <= 10^5s may contain letters, digits, symbols, and spacess = "abcabcbb"Output3WhyThe longest substring without repeated characters is `"abc"`.s = "bbbbb"Output1WhyOnly one unique character can be kept in any valid substring.s = "pwwkew"Output3Why`"wke"` is a longest valid contiguous substring.0 <= len(s) <= 10^5s consists of printable characters, including spaces and symbolsReturn the length of the longest valid substringdef length_of_longest_substring(s):