本文共 615 字,大约阅读时间需要 2 分钟。
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ nlist=[] maxl=min(len(s),1) for i in s: if i in nlist: if i==nlist[-1]: nlist=[i] else: nlist=nlist[nlist.index(i)+1:] nlist.append(i) else: nlist.append(i) l=len(nlist) if l>maxl: maxl=l return maxl
总结:
转载地址:http://zbrbb.baihongyu.com/