int lb=lower_bound(coins,coins+n,money,compare)-coins-1;
what is the use of -1 here, when we have already made a compare functions so that a<=b
int lb=lower_bound(coins,coins+n,money,compare)-coins-1;
what is the use of -1 here, when we have already made a compare functions so that a<=b
@Khushboo2001 That is used to find the element just lesser than or equal to the element. As you can see the video when he did the lower bound for 100 by subtracting -1 it gives a value 50 so when we compare that it will give us a value 100 that is less than or equal to element.
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.