653. Find First and Last Position of Element in Sorted Array
0
Medium
Given an array of integers Arr sorted in ascending order, determine the starting and ending positions of a given target value.
Input Format
The first line of input contains two integers N (the size of the array) and K (the target value).
The second line consists of the array A.
Output Format
Print the pair of integers representing the first and last index of the target element. If the target is not present in the array, print "-1 -1".
Example
Input
6 8
5 7 7 8 8 10
Output
3 4
Constraints
1<=N<= 10^5
-10^5 <= A[i] <= 10^5
Loading...
View Submissions
Console