Skip to content

Commit 2bf7d8c

Browse files
committed
Time: 644 ms (10.24%), Space: 14.2 MB (80.67%) - LeetHub
1 parent 8cf5638 commit 2bf7d8c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s: str) -> int:
3+
maximum = 0
4+
for i in range(len(s)):
5+
sets = set()
6+
sets.add(s[i])
7+
for j in range(i+1, len(s)):
8+
if s[i] != s[j] and s[j] not in sets:
9+
sets.add(s[j])
10+
else:
11+
break
12+
maximum = len(sets) if len(sets) > maximum else maximum
13+
return maximum

0 commit comments

Comments
 (0)