Upper_Bound Function

Sample Input
5
1 2 3 3 4
3
2
3
10
Sample Output
1
3
-1

for the given sample input, why does the output show index 1 and 3?? The upper_bound function returns an andress of element > key. So output should be
2
4
-1

Hello @ritkumar

In the question u are asked to find the index of first and last occurrence of given key.
Note : Last occurrence !=upper bound

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.