Skip to content

Commit e97b0e9

Browse files
committedMay 11, 2025
Feat : Longest Substring Without Repeating Characters
1 parent dc2adcc commit e97b0e9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s):
3+
char_set = set()
4+
left = 0
5+
max_len = 0
6+
7+
for right in range(len(s)):
8+
while s[right] in char_set:
9+
char_set.remove(s[left])
10+
left += 1
11+
char_set.add(s[right])
12+
max_len = max(max_len, right - left + 1)
13+
14+
return max_len

0 commit comments

Comments
 (0)