Money Change Problem

Sir I think after passing the compare function in lower_bound function is working for (>key) condition i.e its working same as upper_bound function but in lecture it is told that its wrking on condition (<=key) which is surely wrong.

hi @akshatjain4545,
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.

Hy @talhashamim001,
ok sr , Thanks

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.

1 Like