Showing posts with label greedy approch. Show all posts
Showing posts with label greedy approch. Show all posts

Thursday, 15 November 2018

Longest Increasing Sub Sequences with Dynamic Programming in Python | C++ | C

# Author Mohd Mujtaba @ Play with C Plus
def LIS(l):
    n=len(l);
    l1=[1]*n;
    for i in range(n):
        for j in range(0,i):
            if(l[i]>l[j]):
                l1[i]=max(l1[j]+1,l1[i]);
    print(max(l1));
for _ in range(int(input())):
    n=int(input());
    l=list(map(int,input().split()));
    LIS(l);
   

Amazon1Ads