LOWER BOUND FUNCTION

IF WE ARE USING COMPARATOR FUNCTION IN LOWER BOUND THEN WHAT IS THE NEED FOR -1?

@Prakhar_Nagpal
if we dont use comparator, then the lower bound function gives the first value in the sorted array that is greater than or equal to the value to be found i.e it will ignore all values smaller than the value to be found. But, when we define a comparator same as defined in the lecture, the lower bound function ignores all the value smaller than or equal to the value to be found and hence will always return the index of key which has value greater than the value to be found.
so basically using comparator in lb make it behaves like upperbound
just try in your compiler for different values you will understand
dont forget to hit like and mark resolved if cleared :smiley:

but what will happen if we remove -1

@Prakhar_Nagpal
example {1,2,3,4,5} , key=3
normal lower bound gives element 3
lower bound -1 will give 2
lower bound with comp gives element 4
lower bound -1 gives element 3
i hope now its clear