We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aba52c3 commit b5b3c4cCopy full SHA for b5b3c4c
1 file changed
longest-substring-without-repeating-characters/hyeri0903.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ def lengthOfLongestSubstring(self, s: str) -> int:
3
+ left = 0
4
+ max_len = 0
5
+ visited = set()
6
+
7
+ for i in range(len(s)):
8
+ while s[i] in visited:
9
+ visited.remove(s[left])
10
+ left += 1
11
12
+ visited.add(s[i])
13
+ max_len = max(max_len, i - left + 1)
14
15
+ return max_len
0 commit comments