Regarding money change problem

There is a video money change problem in which we have to find coins and rupees to make a given sum.
I have commented my doubts https://ide.codingblocks.com/s/445498

Hello @sarthak_singhal take only the example of first case when we will check for 200 first:
using a<=b, comparator function returns true for all elements <= value to be found. When the comparator function returns false at that time we see that the current index might be the answer. If we dont use comparator function, it returns true only for elements < value to be found.

this is because when our comparator will stop it will be at 200 so that s why we have to subtract 1 from that.

at this point we have to do -1 in the index.

and i dint understand what you mean by your another doubt could you please elaborate?

I have now understood the reason for -1 but I can’t understand one thing that how in compare function compiler will decide which integer will be money and which will be lower bound value?

as there are two variables int a and int b in compare function

@sarthak_singhal b will be money and a will be the value from the coins array:
you can check from here:

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.