```
public class Solution {
public int[] searchRange(int[] nums, int target) {
int left = 0;
int right = nums.length - 1;
int mid = 0;
int start = 0;
int end = 0;
int res[] = new int[2];
res[0] = -1;
res[1] = -1;
while(left <= right){
mid = (left + right)/2;
if(nums[mid] == target){
start = mid;
while(start > 0 && nums[start] == nums[start-1]){
start--;
}
end = mid;
while(end < nums.length -1 && nums[end] == nums[end + 1]){
end++;
}
res[0] = start;
res[1] = end;
break;
}
else if(nums[mid] > target){
right = mid - 1;
}
else{
left = mid + 1;
}
}
return res;
}
}
```