Easy to understand solution C++


#1

bool comp(vector A, vector B){
return A[0]<B[0];
}

int Solution::solve(vector<vector > &A) {
sort(A.begin(),A.end(),comp);
int ans=1;
priority_queue <int, vector, greater > pq;
pq.push(A[0][1]);
for(int i=1;i<A.size();i++){
if(A[i][0]>=pq.top()){pq.pop();}
else{ans++;}
pq.push(A[i][1]);
}
return ans;
}


#2

Wonderful Solution…