Money change problem

what is the internal code of lower bound function
and how is the comparator function working
and after passing the compartor function why sir is subtracting 1 from the lb(index number)

@soorya19k
Lower_bound( ) gives us the position of the element that is not smaller than the given number (focus on not).
So the position returned by lower bound will have element either equal to number or it will be greater than the number.(this remains true for the comp passed, infact this comp is similar to internal comp used by LB) Lower_bound uses Binary Search kind of algo.
Now to get the position of element just smaller than number we subtract 1, (as array is sorted in ascending order the previous element must be smaller)
If this resolves your doubt mark it as resolved .

when the ans returned is the value equal to the key then also we are subtracting 1

@soorya19k In this question we have passed a custom comparator that will always return the position of value just greater than key.
So we will always need to subtract 1.
If this solves your doubt mark it as resolved

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.