I know that for this you need to enable some comparison function.
But he does not know how to write for this.
e.g. →
vector elements = {(2,4), (4,2), (5,1), (5,3)}
to find = 5
lower_bound () should return 2
code →
#define pp pair<int,int>
bool cmp(const pp &l,const pp &r)
{
return l.first<r.first
}
int main()
{
vector<pp> v;
sort(v.begin(),v.end(),cmp);
int id=(int)(lower_bound(v.begin(),v.end(),??)-v.begin());
}
source
share