Problem in use of compare function

how is compare fn changing the output as it was said we are changing the condition >=key to <=key but for money =50 it will not change and pass the same address please explain in detail…and how for money=25 also it is working
and giving output please explain the code

hi @himanshuanand729,
ower bound is itself a function it will use tat comparator to comapare the parameters u dont have to mention that, u r changing the behavior of the default lowerbound function usnig comparator
return a<=b in custom compare works like upper_bound(it returns the first value which is not less than or equal to searched value) so lower_bound function with this custom compare will give you value just greater than searched value and subtracting -1 will give you the correct denomination of that money that will be either less than or equals to searched money.

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.