
In Meta Messenger, you need to analyze a text string 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 in which every character appears at most once.
sExample 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". Note that "pwke" is not contiguous, so it does not count.0 <= len(s) <= 5 * 10^4s consists of English letters, digits, symbols, and spacess = "abcabcbb"Output3WhyThe longest substring without repeated characters is `"abc"`.s = "bbbbb"Output1WhyOnly one unique character can appear in any valid substring.s = "pwwkew"Output3WhyA longest valid substring is `"wke"`, which has length 3.0 <= len(s) <= 5 * 10^4s consists of English letters, digits, symbols, and spacesSubstring must be contiguousdef length_of_longest_substring(s):