Skip to content

Instantly share code, notes, and snippets.

@hyperneutrino
Created December 15, 2020 05:50
Show Gist options
  • Save hyperneutrino/a1a1929aa55c8c32b5787ed078a0d0e1 to your computer and use it in GitHub Desktop.
Save hyperneutrino/a1a1929aa55c8c32b5787ed078a0d0e1 to your computer and use it in GitHub Desktop.
a = [1,2,16,19,18,0]
i = [-1] * 30000001
for x,y in enumerate(a): i[y]=x
l = 0
x = len(a) + 1
while x < 30000000:
k = l
if i[l] > -1:
l = x - i[l] - 1
else:
l = 0
i[k] = x - 1
x += 1
print(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment