DC


In Messenger, you need to analyze a typed message and find the length of the longest contiguous substring that contains no repeated characters.
Write a function that takes a string s and returns an integer: the maximum length of any substring of s with all unique characters.
sExample 1
s = "abcabcbb"3"abc", "bca", and "cab", each of length 3.Example 2
s = "bbbbb"1b, so the best answer is "b".Example 3
s = "pwwkew"3"wke" is a valid substring of length 3. "pwke" is not valid because it is not contiguous.0 <= len(s) <= 5 * 10^4s contains English letters, digits, symbols, and spacess = "abcabcbb"Output3WhyThe longest substring without repeating characters is `"abc"`, which has length 3.s = "bbbbb"Output1WhyOnly one unique character can appear at a time, so the longest valid substring has length 1.s = "pwwkew"Output3Why`"wke"` is the longest contiguous substring with all unique characters.0 <= len(s) <= 5 * 10^4s contains English letters, digits, symbols, and spacesA substring must be contiguousdef length_of_longest_substring(s):