class Solution {
public int[] searchRange(int[] nums, int target) {
int n = nums.length;
int l = 0,r = n - 1;
while(l <= r){
int mid = l + (r - l) / 2;
if(nums[mid] == target){
int[] arr = new int[2];
for(int i = mid;i >= 0;i--){
if(nums[i] < target){
arr[0] = i + 1;
break;
}
}
if(nums[0] == target){
arr[0] = 0;
}
for(int i = mid;i < n;i++){
if(nums[i] > target){
arr[1] = i - 1;
break;
}
}
if(nums[n - 1] == target){
arr[1] = n - 1;
}
return arr;
}
if(nums[mid] > target){
r = mid - 1;
}
if(nums[mid] < target){
l = mid + 1;
}
}
int[] brr = {-1,-1};
return brr;
}
}