public int[] searchRange(int[] nums, int target) {
        int[] pos = new int[]{-1, -1};

        int start = 0, end = nums.length-1;

        while(start < end) {
            int mid = start + (end-start)/2;

            if(nums[mid] < target) {
                start = mid + 1;
            } else {
                end = nums[mid]>target?mid-1:mid;
            }
        }

        if(nums[start] != target) {
            return pos;
        }

        pos[0] = start;
        end = nums.length-1;

        while(start < end-1) {
            int mid = start + (end-start)/2;

            if(nums[mid] > target) {
                end = mid -1;
            } else {
                start = mid;
            }
        }

        pos[1] = nums[end]==target?end:start;

        return pos;
    }