Tuesday 23 June 2015



LIS CODE WITH  MULTISET


if  we  required  repeated  elements we use upper_bound(s.begin(),s.end(),g)   if(it!=s.end()) then erase(it);



if repaeated elements are not required then we use---->>>>  s.find(g);  it++;  if(it!=s.end()) then erase(it);


#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int n,g;
    multiset<int> s;
    multiset<int>::iterator it;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>g;
        s.insert(g);
        it = upper_bound(s.begin(), s.end(), g);
        if(it!=s.end())
        s.erase(it);
    }
    cout<<s.size()<<endl;
    return 0;
}

No comments:

Post a Comment

Uploading and Running Lambda function in AWS

Main.go package main import ( "fmt" "encoding/json" "log" "github.com/aws/aws-lambda-g...