Doubt in logic of the program

as we have changed comparator function, now for 120, 100 would be the lower bound then we are subtracting 1 from lb for lower bound ?
i have commented my doubt on the given code .

@Raghavsingla522 due to the compare function, the lower_bound function actually behaves like upper_bound function now, therefore it return the first value that is greater than the key, so we have to subtract 1

but it returns the first value that is greater than the key, then what is the use of that compare function i guess that function is returning the <=key value then how does it behave like an upper bound function ?
please explain . :pray: :pray:

that is exactly what the upper_bound function does.

upper_bound() is a standard library function in C++ defined in the header . It returns an iterator pointing to the first element in the range [first, last) that is greater than value, or last if no such element is found.

returning <= key ensures that only values > key return false, which is what we need.

@Raghavsingla522 please mark the doubt as resolved in case you dont have any further queries.