3. Longest Substring Without Repeating Characters
Tags:
Slide window with hash
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        M = defaultdict(int)
        l = -1
        res = 0
        for i in range(len(s)):
            if s[i] in M:
                l = max(l, M[s[i]])
            res = max(res, i - l)
            M[s[i]] = i
        return res