Skip to content

Instantly share code, notes, and snippets.

@nickyfoto
Created April 26, 2019 01:40
Show Gist options
  • Save nickyfoto/8b85e8123e0900a0ad352f1950dfc885 to your computer and use it in GitHub Desktop.
Save nickyfoto/8b85e8123e0900a0ad352f1950dfc885 to your computer and use it in GitHub Desktop.
Length of Longest Increasing Subsequence
def LIS(a):
"""Longest Increasing Subsequences"""
L = [1] * len(a)
for i in range(len(a)):
for j in range(i):
if a[j] < a[i] and L[i] < 1+L[j]:
L[i] = 1 + L[j]
return max(L)
a = [5,7,4,-3,9,1,10,4,5,8,9,3]
LIS(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment