LeetCode 3. Longest Substring Without Repeating Characters

来源:互联网 发布:windows怎么安装服务 编辑:程序博客网 时间:2024/06/08 02:12
class Solution(object):    def lengthOfLongestSubstring(self, s):        """        :type s: str        :rtype: int        """        dict = {}        maxLen = 0        begin = 0        for ind, val in enumerate(s):            if val in dict and dict[val] >= begin:                begin = dict[val] + 1            dict[val] = ind            maxLen = max(maxLen, ind - begin +1)        return maxLen
阅读全文
0 0
原创粉丝点击