Binary search is internally implemented using lower_bound() as shown:
it = lower_bound(begin, end, x);
if (it != end && !(x < *it))
return true;
else
return false;
How to modify this logic to make it work with upper_bound()?
it = ++upper_bound(begin, end, x);
it = --upper_bound(begin, end, x);
it = upper_bound(begin, end, x);
Not Possible to do it with upper bound
This question is part of this quiz :
C++ STL Non-Mutating Algorithms