Created
May 2, 2021 06:38
-
-
Save Lulzx/0c71c717a5a20b0886e0e2690b915d2e to your computer and use it in GitHub Desktop.
Longest Non Repeating Substring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = "abcabcbb" | |
t = [] | |
c = 0 | |
n = 0 | |
for i in s: | |
if i in t: | |
if c > n: | |
n = c | |
c = 0 | |
t = [i] | |
if len(s) < 2 * len(t): | |
break | |
else: | |
t.append(i) | |
c = len(t) | |
print(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment