Doubt in compare()?

In compare(), we used return a<=b,
acc to this the lower_bound() should return the value either equal to key or just smaller than the key i.e if key=120, we should either get 120 or 100, but if we do so, in both cases we’ll get 200.

hi @amandeepdogra65 lower_bound() using this compare function, will return the value that is strictly greater than the key.

Can you explain how a<=b changes the behaviour?

@amandeepdogra65 it will return the value that returns false for the comparison a <= b

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.