
Spotify tracks user activity strings where each character represents an event type. Given a string s, return the length of the longest substring without repeating characters.
A substring is a contiguous sequence of characters within the string. You must design an algorithm better than checking all possible substrings.
ss that contains no duplicate charactersExample 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". "pwke" is not valid because it is not contiguous.0 <= len(s) <= 5 * 10^4s consists of English letters, digits, symbols, and spacess = "abcabcbb"Output3WhyThe longest substring without repeating characters is `"abc"`.s = "bbbbb"Output1WhyOnly one unique character can appear in any valid substring, so the maximum length is 1.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 spacesThe answer must be computed in better than O(n^2) time for large inputsdef length_of_longest_substring(s):