I am unable to understand coin change solution. What i am getting through int idx = upper_bound.
I am not sure about coins , coins+n, money)-1 -coins.
I am unable to understand coin change solution. What i am getting through int idx = upper_bound.
I am not sure about coins , coins+n, money)-1 -coins.
@Ans
Hello Arun,
upper_bound(coins,coins+n,money)-coins -> this is returning us index in array whose value is just greater than money.
now when we do -1 to above index it will give the index whose value will be either equal to or less than money.
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.