publicstaticintbinarySearch(int[] nums, int target) {
int begin = 0;
int end = nums.length - 1;
int medium = 0;
while (begin <= end) {
medium = (begin + end) / 2;
if (nums[medium] > target) {
end = medium - 1;
} elseif (nums[medium] < target) {
begin = medium + 1;
} else {
while (medium > 0 && nums[--medium] == target);
if (medium == 0){
return medium;
}else {
return ++medium;
}
}
}
return -1;
}