public class Solution
{
public int Search(int[] nums, int target)
{
var len = nums.Length; var low = ;
var high = len - ;
if (target == nums[low])
{
return low;
}
else if (target == nums[high])
{
return high;
}
while (low < high)
{
var mid = (low + high) / ;
var cur = nums[mid]; if (target == cur)
{
return mid;
}
else if (target < cur)
{
high = mid - ;
}
else
{
low = mid + ;
}
}
return -;
}
}
05-12 20:27