Given a sorted array of integers arr and a target value, return the index of the first occurrence of target in arr. If target is not present, return -1.
Input
arr: array of integers sorted in non-decreasing order
target: integer to locate
Output
The smallest index i such that arr[i] === target, or -1 if no such index exists.
Examples
Example 1
Inputarr = [1, 3, 3, 3, 3, 6, 10, 10, 10, 100], target = 3
Output1
Example 2
Inputarr = [2, 3, 5, 7, 11, 13, 17, 19], target = 6
Output-1
Constraints
0 <= arr.length <= 10^5
arr is sorted in non-decreasing order; duplicates are allowed.