Advertisement
Riz1Ahmed

Longest Increasing Subsequence

Feb 19th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4. int main(){
  5.     int ar[]={2,3,1,4,7,8,10,2,3,9};
  6.     int n=sizeof(ar)/sizeof(ar[0]);
  7.     int i,c=1,mx=-1;
  8.     for(i=1; i<n; i++){
  9.         if (ar[i-1]<ar[i]) c++;
  10.         else mx=max(mx,c),c=1;
  11.     }
  12.     mx=max(mx,c);
  13.     printf("%d\n",mx);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement