how {5,15} coming top in priority quiz
Query in ques no.11 of stl quiz1
Hey @harry_potter123
The structure of the comparator given in the question is:
struct Compare
{
bool operator()(pi const & a, pi const & b)
{
if(a.second < b.second)
{
return true;
}
else if(a.second > b.second)
{
return false;
}
else
{
if(a.first > b.first)
{
return true;
}
return false;
}
}
};
According to this comparator, the sorting will be like:
the one with greater second will be on top, and if two of them have same second, the one with smaller first will be on top,
so greatest second is for 15, and in the two pairs having second as 15(7, 15 & 5, 15), smallest first is of 5. so 5,15 is the ans.