目录

​一、题目描述​

​二、题解​

​三、源码​


一、题目描述

LeetCode刷题——无重复字符的最长子串_python

 二、题解

LeetCode刷题——无重复字符的最长子串_leetcode_02

三、源码

 

class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
cur, res = [], 0
for r in range(len(s)):
while s[r] in cur:
cur.pop(0) # 左边出
cur.append(s[r]) # 右侧无论如何都会进入新的
res = max(len(cur),res)
return res