只要写不死,就要写下去
题目描述,略了
手写一下滑动窗口加哈希表的解题思路
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
res,dic,i=0,{},-1
for j in range(len(s)):
if s[j] in dic:
i= max (dic[s[j]],i)
dic[s[j]]=j
res=max(res,j-i)
return res