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 f651ab1 commit 6c88f0eCopy full SHA for 6c88f0e
longest-substring-without-repeating-characters/naringst.py
@@ -0,0 +1,22 @@
1
+
2
+# Runtime: 51ms, Memory: 16.83MB
3
+# Time complexity: O(len(s))
4
+# Space complexity: O(len(s))
5
6
+class Solution:
7
+ def lengthOfLongestSubstring(self, s: str) -> int:
8
+ stringArr = []
9
+ maxLength = 0
10
11
+ for sub in s :
12
+ if sub in stringArr :
13
+ maxLength = max(maxLength, len(stringArr))
14
+ repeatIdx = stringArr.index(sub)
15
+ stringArr = stringArr[repeatIdx+1 :]
16
17
+ stringArr.append(sub)
18
19
20
21
22
+ return maxLength
0 commit comments