c 2b 2b custom compare in set

Solutions on MaxInterview for c 2b 2b custom compare in set by the best coders in the world

showing results for - "c 2b 2b custom compare in set"
Julian
08 Jan 2020
1struct compare {
2    bool operator() (const int& x, const int& y) const {
3        return x<y; // if x<y then x will come before y. Change this condition as per requirement
4    }
5};
6int main()
7{
8  set<int,compare> s; //use the comparator like this
9}