From 55fbc758554acf78f9509f481c4e264739b2d308 Mon Sep 17 00:00:00 2001 From: aditya-11-19 <59506598+aditya-11-19@users.noreply.github.com> Date: Sat, 2 Oct 2021 23:06:43 +0530 Subject: [PATCH] Create DP- Longest Strictly Increasing Subsequence #378 This is my code for https://practice.geeksforgeeks.org/problems/longest-increasing-subsequence-1587115620/1 --- ...P- Longest Strictly Increasing Subsequence | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Dynamic Programming/C++/DP- Longest Strictly Increasing Subsequence diff --git a/Dynamic Programming/C++/DP- Longest Strictly Increasing Subsequence b/Dynamic Programming/C++/DP- Longest Strictly Increasing Subsequence new file mode 100644 index 00000000..f8ac1129 --- /dev/null +++ b/Dynamic Programming/C++/DP- Longest Strictly Increasing Subsequence @@ -0,0 +1,34 @@ +// LONGEST INCREASING(STRICTLY) SUBSEQUENCE +// https://practice.geeksforgeeks.org/problems/longest-increasing-subsequence-1587115620/1 +// In this problem, we have to find the length of the longest strictly subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order. + +// Example:- Sequence- {8,100,150,10,12,14,110} +//Length of longest subsequence- 5 // (8,10,12,14,110) + +//Time Complexity- O(N^2) +//Space - O(N) + +int LIS (int a[],int n) +{ + int li[n]; + li[0]=1; + for(int i=1;ia[j]) + { + li[i]=max(li[i],li[j]+1); + } + } + } + int res=1; + + for(int i=0;i