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 3b17347 commit 89c6f0bCopy full SHA for 89c6f0b
longest-substring-without-repeating-characters/samthekorean.py
@@ -0,0 +1,16 @@
1
+# TC : O(n)
2
+# SC : O(n)
3
+class Solution:
4
+ def lengthOfLongestSubstring(self, s: str) -> int:
5
+ charSet = set()
6
+ left = 0
7
+ longest_length = 0
8
+
9
+ for right in range(len(s)):
10
+ while s[right] in charSet:
11
+ charSet.remove(s[left])
12
+ left += 1
13
+ charSet.add(s[right])
14
+ longest_length = max(longest_length, right - left + 1)
15
16
+ return longest_length
0 commit comments