From a1d248ef0e4005bba92d800622df0b445b25e691 Mon Sep 17 00:00:00 2001 From: Neeraj Pathak <73093507+Nucleoo@users.noreply.github.com> Date: Mon, 19 Oct 2020 12:19:24 +0530 Subject: [PATCH] LIS(nlogn).cpp Algorithm for finding the length of the Longest Increasing Subsequence in O(NlogN) --- dynamic_programming/LIS(nlogn).cpp | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 dynamic_programming/LIS(nlogn).cpp diff --git a/dynamic_programming/LIS(nlogn).cpp b/dynamic_programming/LIS(nlogn).cpp new file mode 100644 index 00000000..2a139b74 --- /dev/null +++ b/dynamic_programming/LIS(nlogn).cpp @@ -0,0 +1,55 @@ +#include +using namespace std; +const int N=2e5+5; +//const int mod = 998244353; +const int mod = 1e9+7; +#define pb push_back +#define mp make_pair +#define sz size +#define fi first +#define se second +#define nl "\n" +#define ps(x) fixed<& arr, int n) { + if(n<=1) return n; + vectordp; + dp.push_back(arr[0]); + for(int i=1; i>n; + vectorarr(n); + for(int i=0; i>arr[i]; + } + int res=LIS(arr, n); + cout<>T; + for(int i=1; i<=T; i++) code(); + + #ifndef ONLINE_JUDGE + cerr<<"Actual : "<<1.0*clock()/CLOCKS_PER_SEC<<" sec\n"; + #endif + return 0; +}