Windows 7 Issues with understanding the Longest Increasing Subsequence code


New Member
Hello all,

I am having issues understanding the code posted on this blog for the Longest Increasing Subsequence problem. I've been trying to implement the code, but I haven't been able to get the correct output. The code I've been trying to implement is as follows:
def LIS(A):
    n = len(A)
    lis = [1]*n
    for i in range (1 , n):
        for j in range(0 , i):
            if A[i] > A[j] and lis[i]< lis[j] + 1 :
                lis[i] = lis[j]+1
    maximum = 0
    for i in range(n):
        maximum = max(maximum , lis[i])
    return maximum

I've tried to debug it, but I'm still having issues. Can someone please help me understand what I'm doing wrong?

Thank you!
Last edited by a moderator: