My Soln using custom sort


#1

Comment body goes here.struct comp{
bool operator()(const pair<int,int> a,const pair<int,int> b){
return abs(a.first)<abs(b.first);
}
};
int Solution::solve(vector<vector > &A) {
vector<pair<int,int> > v;
for(int i = 0 ; i <A.size();i++){
v.push_back({A[i][0],1});
v.push_back({-A[i][1],0});
}
sort(v.begin(),v.end(),comp());
int count = 0;
int maxans = 0;
for(int i = 0;i<v.size();i++){
// cout<<v[i].first<<" ";
if(v[i].first>0){
count++;
}
else{
count–;
}

    maxans = max(maxans,count);
}
return maxans;

}