Is it necessary that the upper_bound and lower_bound should be applied only on the ascending order sorted arrays?
Upper_bound and lower_bound function
Yes they work only on sorted arrays. By default they work on ascending order sorted array.
If array is sorted in descending ordered, then you would have to pass an extra parameter
low = lower_bound(v.begin(), v.end(), 3, greater<int>()); `
up = upper_bound(v.begin(), v.end(), 5, greater<int>()); `
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.