C++ sorting se ho jayega


#1
int Solution::solve(vector<vector<int> > &A) {
    if(A.size()==1)
        return 1;
    vector<pair<int,int> > v;
    for(int i=0;i<A.size();i++){
        v.push_back(make_pair(A[i][0],A[i][1]));
    }
    sort(v.begin(),v.end());
    int i=0,j=1;
    int cnt =1;
    while(j<v.size()){
        if(v[j].second<v[i].second){
            i=j;
            j++;
        }
        else if(v[j].first>v[i].second){
            cnt++;
            i=j;
            j++;
        }
        else
            j++;
    }
    return cnt;
}