Skip to content

Commit 2966f83

Browse files
committed
committed from zkp
1 parent d20157d commit 2966f83

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s):
3+
"""
4+
:type s: str
5+
:rtype: int
6+
"""
7+
if s == '':
8+
return 0
9+
u = []
10+
t = len(s)
11+
# 这是一个移动窗口,先固定i再对j相加
12+
for i in range(t):
13+
j = i
14+
while s[j] not in s[i:j] :
15+
j += 1
16+
if t == j:
17+
break
18+
u.append(s[i:j])
19+
t = sorted(u, key=lambda x:len(x), reverse=True)[0]
20+
return len(t)

0 commit comments

Comments
 (0)