Given a sorted array of integers, find the index of the first occurrence of a target element using binary search. If the target is not found, return -1.
Input:
Output:
Example 1
Input: 1 2 2 3 4 2
Output: 1
The first occurrence of 2 is at index 1 in the sorted array
Constraints
Hints
Given a sorted array of integers, find the index of the first occurrence of a target element using binary search. If the target is not found, return -1.
Input:
Output:
Example 1
Input: 1 2 2 3 4 2
Output: 1
The first occurrence of 2 is at index 1 in the sorted array
Constraints
Hints