Showing posts with label list. Show all posts
Showing posts with label list. 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);
   

Tuesday, 14 March 2017

Enumeration Example

#include<iostream>
using namespace std;
main()
{
enum{ jan=1,feb,m,a,ma,ju,jul,au,sep,oct,nov,december };//Enumeration Variables
cout<<december;
}/*If We do not Initialize the Value of Enum Then By default value is 0 ..Then Jan will start from 0 and print 11 for december month */

Amazon1Ads