Skip to content

Commit d0cf709

Browse files
Merge pull request #31 from Rajkushwaha0/New-Question
Longest Substring Without Repeating Characters
2 parents 68e797a + 822025d commit d0cf709

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s: str) -> int:
3+
l=0
4+
res=0
5+
charset=set()
6+
for r in range(len(s)):
7+
while(s[r] in charset):
8+
charset.remove(s[l])
9+
l+=1
10+
charset.add(s[r])
11+
res=max(res,r-l+1)
12+
return (res)

0 commit comments

Comments
 (0)