classSolution{ publicint[] searchRange(int[] nums, int target) { if (nums == null || nums.length == 0) returnnewint[]{-1, -1}; int smallest = findSmall(nums, target); int highest = findHigh(nums, target); int[] res = newint[]{smallest, highest}; return res; } privateintfindSmall(int[] nums, int target){ int left = 0; int right = nums.length - 1; int res = -1; while(left <= right){ int mid = (left + right) / 2; if (nums[mid] == target) res = mid; if (nums[mid] >= target) right = mid - 1; else left = mid + 1; } return res; } privateintfindHigh(int[] nums, int target){ int left = 0; int right = nums.length - 1; int res = -1; while(left <= right){ int mid = (left + right) / 2; if (nums[mid] == target) res = mid; if (nums[mid] <= target) left = mid + 1; else right = mid - 1; } return res; } }