小黑代码(与官方题解思路一致)
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        # 字符串长度
        n = len(s)
        # 定义双指针
        head = 0
        tail = 0
        # 窗口集合
        set_ = set()
        # 结果变量
        result = 0
        while tail < n:
            # 该字符不在集合里
            if s[tail] not in set_:
                set_.add(s[tail])
                tail += 1
                if tail-head > result:
                    result = tail - head
            # 该字符在集合里
            else:
                set_.remove(s[head])
                head += 1
        return result
 

小黑生活
咖啡蛋糕算法

 
 
祝贺阿黄警察公务员上岸,感谢宴请潮汕牛肉火锅

 
 
 
 
 
 
 
 
tims咖啡算法

小汤3《布吉乌吉舞曲》打卡

晚上包鹏淹哥一起约饭啊

 
 
 
 
 
 
 
八卦八卦

尝试一下美白

逛了逛某人的qq空间,发现初中老照片,怪怀念的


宇飞牛肉面

骑车找小老黑鸟巢遛弯

 
 
 
喜茶咖啡蛋糕学习

 














![[C++]lambda](https://img-blog.csdnimg.cn/0f8ce8e5098a48bf9c76ecea29d87592.png)



