Skip to content

Commit 4f7b9aa

Browse files
committed
leetcode_problem2
1 parent 7b4d61c commit 4f7b9aa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s: str) -> int:
3+
m=0
4+
if len(s)==0 :
5+
return 0
6+
if len(s)==1 or s==" ":
7+
return 1
8+
for i in range (0, len(s)-1):
9+
ss=s[i]
10+
for j in range (i+1, len(s)):
11+
if s[j] not in ss:
12+
ss+=s[j]
13+
else:
14+
break
15+
if m<len(ss):
16+
m=len(ss)
17+
18+
return m

0 commit comments

Comments
 (0)