class Solution: def lengthOfLongestSubstring(self, s): dic, res, start, = {}, 0, 0 for i, ch in enumerate(s): if ch not in dic or (ch in dic and dic[ch]<start): res = max(res, i-start+1) else: start = dic[ch]+1 dic[ch] = i return res
leetcode#3. 无重复字符的最长子串
猜你喜欢
转载自www.cnblogs.com/lsaejn/p/9716576.html
今日推荐
周排行