Created
April 26, 2019 01:40
-
-
Save nickyfoto/8b85e8123e0900a0ad352f1950dfc885 to your computer and use it in GitHub Desktop.
Length of Longest Increasing Subsequence
This file contains hidden or 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
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