class Solution(object):

    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        # """
        pos = dict()
        maxl = 0
        l = 0
        for i in range(len(s)):
            if s[i] in pos:
                l = i - pos[s[i]]
            else:
                l += 1
            pos[s[i]] = i
            maxl = max(maxl, l)
        return maxl

83e1f78ff8ac797c410aeeb6a46ba1bf27cccc62
<mask token>

class Solution(object):
    <mask token>

class Solution(object):

    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        # """
        pos = dict()
        maxl = 0
        l = 0
        for i in range(len(s)):
            if s[i] in pos:
                l = i - pos[s[i]]
            else:
                l += 1
            pos[s[i]] = i
            maxl = max(maxl, l)
        return maxl
