Skip to content

Instantly share code, notes, and snippets.

@r0c
Created August 14, 2015 05:09
Show Gist options
  • Save r0c/e884278fdbe872daf1ac to your computer and use it in GitHub Desktop.
Save r0c/e884278fdbe872daf1ac to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import random
def getL(list, n, maxlenoverall):
if n == 0:
return 1
maxlen = 1
for i in range(n):
res = getL(list, i, maxlenoverall)
if list[n] > list[i] and maxlen < res + 1:
maxlen = res + 1
if maxlenoverall[0] < maxlen:
maxlenoverall[0] = maxlen
return maxlen
if __name__ == "__main__":
list = [random.randint(1, 20) for _ in range(10)]
print "---" * 8 + str(list) + "---" * 8
maxlenoverall = [1]
getL(list, len(list) - 1, maxlenoverall)
print maxlenoverall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment