I had a vector of pairs. I wanted it sorted in descending according to the first value of the vector. ↵
↵
~~~~~↵
sort(a.begin(),a.end(),[](pair<int,int> &left, pair<int,int> &right){↵
return left.first >= right.first;↵
});↵
~~~~~↵
↵
This gave me TLE. Sorting it normally ↵
↵
~~~~~↵
sort(a.begin(),a.end());↵
~~~~~↵
↵
and iterating from the end worked. ↵
↵
Why does the first sorting function give TLE? Do I have to implement it some other way?↵
↵
↵
~~~~~↵
sort(a.begin(),a.end(),[](pair<int,int> &left, pair<int,int> &right){↵
return left.first >= right.first;↵
});↵
~~~~~↵
↵
This gave me TLE. Sorting it normally ↵
↵
~~~~~↵
sort(a.begin(),a.end());↵
~~~~~↵
↵
and iterating from the end worked. ↵
↵
Why does the first sorting function give TLE? Do I have to implement it some other way?↵
↵