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 5527467 commit 5f2019fCopy full SHA for 5f2019f
longest-substring-without-repeating-characters/jeldo.py
@@ -0,0 +1,14 @@
1
+class Solution:
2
+ # O(n), n = len(s)
3
+ def lengthOfLongestSubstring(self, s: str) -> int:
4
+ max_len = 0
5
+ chars = dict()
6
+ l = 0
7
+ for r in range(len(s)):
8
+ if s[r] not in chars or chars[s[r]] < l:
9
+ chars[s[r]] = r
10
+ max_len = max(max_len, r - l + 1)
11
+ else:
12
+ l = chars[s[r]] + 1
13
14
+ return max_len
0 commit comments