找工作-最长不重复字符

s = 'aaabbacccc'


def max_length_substring(s):
item_list = []
item_max = 0
for i in s:
if i not in item_list:
item_list.append(i)
else:
if item_max < len(item_list):
item_max = len(item_list)
item_list = [i]

if item_max < len(item_list):
item_max = len(item_list)
return item_max

print(max_length_substring(s))
posted @ 2019-12-03 21:24  CoyLee  阅读(144)  评论(0编辑  收藏  举报