How to use upper bounnd

vector thefunciton(vector& A, vector& B) {

}

suppose this is function which i have to complete.
and in this fucntion i need to apply upper_bound.
as the upper bound return the address of the element in this case how i will use this?

@gagz23
int a[]= {1 , 2 , 2 , 2 , 2 , 4 ,7};
int n = 7;

int id1 = lower_bound(a , a+n , 2)-a;
int id2 = upper_bound(a , a+n , 2)-a;
cout<<“first occurence of 2 is->”<<id1<<endl; // 1
cout<<“last occurence of 2 is->”<<id2<<endl; // 5
cout<<“Total occurences of 2 ->”<<(id2-id1)<<endl; // 4

int id3 = lower_bound(a , a+n , 3)-a;

int id4 = upper_bound(a , a+n , 3)-a;
cout<<“first occurence of 3 is->”<<id3<<endl; //5
cout<<“last occurence of 3 is->”<<id4<<endl; //5
cout<<“Total occurences of 2 ->”<<(id4-id3)<<endl; //0

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.

noo i know how to apply upper bound on array or vcetor… but iam asking

vector thefunciton(vector& A, vector& B) { how i will use upper bound here }

vector thefunciton(vector& A, vector& B) { how i will use upper bound here }

hello @gagz23 just confirming how can you apply upper and lower bound in the function calls? right?

yes when arr is passed as &arr

see its the function call you cant do these things there.
you have to do thus inside the function or in main.
while passing the function call or in the function call you cannot perform any operation. it will give you an error.

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.