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 e06a675 commit d0c1a2aCopy full SHA for d0c1a2a
1 file changed
longest-substring-without-repeating-characters/gyeo-ri.py
@@ -0,0 +1,23 @@
1
+class Solution:
2
+ def lengthOfLongestSubstring(self, s: str) -> int:
3
+ longest_substring: str = ""
4
+ current_substring: str = ""
5
+
6
+ for c in s:
7
+ if len(longest_substring) < len(current_substring):
8
+ longest_substring = current_substring
9
10
+ if c not in set(current_substring):
11
+ current_substring += c
12
13
+ else:
14
+ current_substring = current_substring.split(c)[1] + c
15
16
17
18
+ return len(longest_substring)
19
20
21
+if __name__ == "__main__":
22
+ s = Solution()
23
+ print(s.lengthOfLongestSubstring("a"))
0 commit comments