public class SearchRange {
public int[] searchRange(int[] nums, int target) {
int left=0;
int right=nums.length-1;
int[] res={-1,-1};
while (left<=right){
if (nums[left]==target){
res[0]=left;
}else left++;
if (nums[right]==target){
res[1]=right;
}else right--;
if (res[0]!=-1&&res[1]!=-1)break;
}
return res;
}
public static void main(String[] args) {
SearchRange a=new SearchRange();
int[] b={5,7,7,8,8,10};
a.searchRange(b,8);
}
}