Loading repovive.com/problems/classics/26
Given a sorted array of n integers in non-decreasing order and a target value x, find the index of the first occurrence of x in the array.
Output the 1-indexed position, or −1 if x is not found.
5 3 1 2 3 4 5
For this input, the required output is 3.
3
5 6 1 2 3 4 5
For this input, the required output is -1.
-1
7 2 1 2 2 2 3 4 5
For this input, the required output is 2.
2