Lower_bound comparator

when we are using lower bound comparator then why we are subtracting 1 from it?
and how exactly comparators perform pls explain?

@akshitagarg15
lower_bound function returns the index of the next smallest number just greater than that number(number u have given in argument ley say x).
subtracting -1 from that index will either give u index of x or index of element just less than x

@akshitagarg15
its internal implementation is very much similar to binary search.
check this out -

https://en.cppreference.com/w/cpp/algorithm/lower_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.