At 4:00 i have a doubt in lecture

in upper_bound line…why are we subtracting-1 and then -coins.
will it not work if we directly do -1 or do -coins?

@dipeshpandey2001
int idx=upper_bound(…) -coins
gives you the index of the element which is the upper bound of the current value but we need to take the element less than it so we subtract -1
auto idx=upper_bound(…) gives us a iterator at that position but if we want the index we need to do -coins
and that additional -1 can also be done later after finding the index
if you still have any dout feel free to ask and if clear mark it as resolved and rate my experience

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.