Improved upon the idea of tutorial for longest increasing subsequence on geeks for geeks and solved it easily in one go without the help of any hint.
Here is a sweet and simple implementation of the above.
#include<bits/stdc++.h>using namespace std;int main(){int n; cin>>n;vector<int> a(n),l(n,1);//a is element array,l is longest increasing subsequence at l[i]vector<bool> s(n);//s is sign array 1 for positive and 0 for negativefor(int i=0;i<n;i++){cin>>a[i];if(a[i]>0)s[i]=1;elses[i]=0;}for(int i=1;i<n;i++)
Read more… (37 words)