
In Meta Messenger, you are given a string s representing a message. Return the length of the longest substring that contains no repeated characters.
A substring must be contiguous. You should solve this efficiently for large inputs.
ss with all unique charactersExample 1
s = "abcabcbb"3"abc", which has length 3.Example 2
s = "bbbbb"1"b".Example 3
s = "pwwkew"3"wke". "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 with all distinct characters is `"abc"`.s = "bbbbb"Output1WhyOnly one unique character can appear in any valid substring, so the answer is 1.s = "pwwkew"Output3Why`"wke"` is a longest valid substring. Longer candidates contain repeated characters or are not contiguous.0 <= len(s) <= 10^5s consists of printable characters, including letters, digits, symbols, and spacesReturn the length of the longest valid substringdef length_of_longest_substring(s):