#include
#include
#include
using namespace std;
int main()
{
sets;
s.insert(1);
s.insert(5);
s.insert(7);
s.insert(2);
s.insert(12);
s.insert(10);
auto it = s.upper_bound(15);
cout<< *it <<endl;
return 0;
}
How is the answer 6 and not garbage value?
in the case when the element being searched is greater than the maximum element the set the returned value is number of elements in the set which in this case is 6.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.