Relative Content

Tag Archive for c++comparator

Why we need to add const in the custom comparator in C++

vector<vector<int>>& intervals auto comp = [](const vector<int>& a, const vector<int>& b) { return a[0] < b[0]; }; auto it = upper_bound(intervals.begin(), intervals.end(), newInterval, comp); I am not very familiar with C++ and was confused about how comparator works. The above code is how I can find the position I want to insert a new interval, […]