Money Change Problem

lower_bound() returns the first element which is not less than a given element,so we passed our comparator to reverse its function.

So if we pass 100 why are we not getting 50 back?We have also subtracted a -1 in the code ??I didnt understand how its working

as u said ki reverse ho raha h
this would always will us the next value which is greater than val whose lower bound is being searched
so
for 100 we would get 200 after the cmp function has been made and hence we substract 1 from it to get the actual result

he is trying to explain that the primitive lower_bound function does not work the way we require
like 120 would give 100
but 100 would give answer 50
hence we use a comparator

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.