Given a sorted array of integers nums and an integer target, return the indices of the first and last appearance of target in nums. If target is not found, return [-1, -1]. Input Format: The first line contains a space-separated sorted array of integers. The second line contains the target integer. Output Format: A space-separated array of two integers representing the first and last indices of the target element.
Example 1
Input: 5 7 7 8 8 10 8
Output: 3 4
The first occurrence of 8 is at index 3 and the last occurrence is at index 4.
Constraints
Hints
Given a sorted array of integers nums and an integer target, return the indices of the first and last appearance of target in nums. If target is not found, return [-1, -1]. Input Format: The first line contains a space-separated sorted array of integers. The second line contains the target integer. Output Format: A space-separated array of two integers representing the first and last indices of the target element.
Example 1
Input: 5 7 7 8 8 10 8
Output: 3 4
The first occurrence of 8 is at index 3 and the last occurrence is at index 4.
Constraints
Hints