Why we subtracted 1 from the obtained index

after lower_bound(coins,coins+n,money,compare)-coins.

And one more thing,please explain me the concept behind bool compare function,i.e how come we know that if a<=b then we would get index less than equal to the given value.

@Harshit-Jha-2364832040305354 we subtract one because array indexing is 0 based.Also bool compare function is used to compare two elemnts of rray while sorting usi ke basis pr pura array sort hota hai internally using sort function apko bs two elements ke compare ka logic likhna hota hai jis condition me apko chyy us condition se true return krao and pass in sort function,it will sort it.

Sir,then normal lower_bound fuction mein hm 1 kyun nhi subtract kr rhe hai,aur comparator ke case mein kyun kr rhe hai.

In both case indexing starts from zero.Sir,please explain the logic behind this in an explained manner.

@Harshit-Jha-2364832040305354 Normal lower bound hme woh element ka index deta hai jo us finding element ke brabar ho ya usse bda ho ,but hme is question me woh wala elent chyy jo finding element se chota ho to lowerbound jo return krega woh ek bda krega to hme use ek chota chyy islie - 1 kia

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.