无重复字符的最长子串
无重复字符的最长子串 - LeetCode (中国) https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/description/
class Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ len_ = len(s) if len_ == 0: return 0 r, memory_ = 1, '' for i in range(len_): item_ = s[i] if item_ in memory_: memory_ = memory_[memory_.find(item_) + 1:] memory_ = '{}{}'.format(memory_, item_) r = max(len(memory_), r) return r