int* searchRange(int* nums, int numsSize, int target, int* returnSize){ int* arr = (int*)calloc(sizeof(int), 2); arr[0] = -1; arr[1] = -1; *returnSize = 2; if (numsSize == 0) return arr; int left = 0, right = numsSize - 1, mid = (left + right) / 2, val; while (left <= right){ mid = (left + right) / 2; if (nums[mid] < target) left = mid + 1; else if (target < nums[mid]) right = mid - 1; else{ while (left <= mid && nums[left] != nums[mid]) left++; while (right >= mid && nums[right] != nums[mid]) right--; arr[0] = left; arr[1] = right; return arr; } } return arr; }