Explain the code


plse explain this code. I am not able to understand the modified function of lower_bound.

See this How does compare function works here

but if we want to find an element which is already pesent then it will do a<=b, in that case a=b, so it will return index to the value which we want to have but then also we are subtracting -1 , why?

plse explain
this code

@Suruchi a<=b does not mean it will return the value less than or equal to searched value its the opposite. it will return value which is not less than or equal to searched values hence can be treated as upper bound.

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.

but if we consider the case of sorting and if we want to do it in descending order , we write a>b, i.e., when we encounter a greater element then only it should return true,right but in this case,we are returning a<=b, i.e. it should return true only when it is less or equal, then how is it working as upper bound?I can’t understand.