Given a sorted array of integers, find the index of the last 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: 2
The last occurrence of 2 is at index 2 in the sorted array
Constraints
Hints
Given a sorted array of integers, find the index of the last 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: 2
The last occurrence of 2 is at index 2 in the sorted array
Constraints
Hints