in money exchange problem
why sir has taken int lb=lower_bound(coins,coins+n,compare)-coins-1;
minus 1should not have been there right???
Algorithm library.... money exchange problem
Hey @sneha23, -1 is needed over there. As suppose you have money 120 then lower_bound will give you value of 200 but when we do -1 it will give you value 100 . Moreover you will be thinking then why did we used comparator function. It’s for the case if you have money equal to 100. Cause if you don’t use comparator function then it will give you value of 50, which is wrong. Hope this will help you 
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.