标签:
要判断最后一个不重复的子串是不是最长
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if len(s)<=1: return len(s) point=0 maxl=0 for index in range(1,len(s)): if s[index] in s[point:index]: l=index-point if l>=maxl: maxl=l point+=s[point:index].index(s[index])+1 if index-point+1>maxl: maxl=index-point+1 return maxl
Leetcode 3. Longest Substring Without Repeating Characters(python)
标签:
原文地址:http://www.cnblogs.com/colorss/p/5326735.html