class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
memary = {}
best,temp = 0,0
for i in range(len(s)):
if s[i] in memary:
temp = max(memary[s[i]],temp)
best = max(i-temp+1,best)
memary[s[i]] = i+1
return best
github项目地址:https://github.com/JockWang/LeetCode-Python