Activity search

#include
#include<bits/stdc++.h>
using namespace std;

bool comp(const pair<int, int>&x, const pair<int, int>&y){
return x.second < y.second;
}

int solve(vector<pair<int,int>>v){
vector<pair<int,int>>::iterator itr1;
vector<pair<int,int>>::iterator itr2;
int cnt = 1;
for(itr1 = v.begin(), itr2 = v.begin()+1; itr2 != v.end(); ++itr2){

    if(itr2->first >= itr1->second){
        itr1 = itr2;
        cnt++;
    }
}
return cnt;

}

int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
vector<pair<int,int>>v;
int s, e;
for(int i = 0; i < n; i++){
cin>>s>>e;
v.push_back(make_pair(s, e));
}
sort(v.begin(), v.end(), comp);

    ///vector<pair<int,int>>:: iterator itr;
    /*
    for(itr = v.begin(); itr != v.end(); ++itr){
        cout<<itr->first<<" "<<itr->second<<endl;
    }
    */
    cout<<solve(v)<<endl;
}
return 0;

}
sir my code is not comiling it getting back l provide the solution

@karthik1989photos please share your code using CB IDE

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.