Skip to content

Commit fcd7ce7

Browse files
authored
Create 3-Longest-Substring-Without-Repeating-Characters.py
1 parent aaca756 commit fcd7ce7

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+
charSet = set()
4+
l = 0
5+
res = 0
6+
7+
for r in range(len(s)):
8+
while s[r] in charSet:
9+
charSet.remove(s[l])
10+
l += 1
11+
charSet.add(s[r])
12+
res = max(res, r - l + 1)
13+
return res

0 commit comments

Comments
 (0)