Skip to content

Instantly share code, notes, and snippets.

@Lulzx
Created May 2, 2021 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lulzx/0c71c717a5a20b0886e0e2690b915d2e to your computer and use it in GitHub Desktop.
Save Lulzx/0c71c717a5a20b0886e0e2690b915d2e to your computer and use it in GitHub Desktop.
Longest Non Repeating Substring
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