index=upper_bound(a,a+n,money) what does this line does??
What are the similar such function
lower_bound
UPPER_bound function usage
Hi @dakshi
upper_bound() function in C++ that returns an iterator pointing to the first element in the range [first, last) that is greater than value, or last if no such element is found. One thing to note in dis is that array should already be sorted.
so index=upper_bound(a,a+n,money) makes the index point to the first location with value greater than money.
similarly
lower_bound() function in C++ that returns an iterator pointing to the first element in the range [first, last) that is equal to the value(if not equal to any element ponts to first element greater than the value) One thing to note in dis is that array should already be sorted.
Hope dis helps.
If still something is unclear, feel free to post ur doubts here.
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.