标签:
题目如下:
Python代码:
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ string = [] length = 0 max = 0 for i in range(len(s)): if s[i] not in string: string.append(s[i]) else: pos = string.index(s[i]) if pos<len(string)-1: string = string[string.index(s[i])+1:] else: string = [] string.append(s[i]) if len(string)>max: max = len(string) return max
Longest Substring Without Repeating Characters
标签:
原文地址:http://www.cnblogs.com/CQUTWH/p/5934616.html