class Solution {
public int searchInsert(int[] nums, int target) {
int i=0;
int j=nums.length-1;
while (i<=j){
int m = i+(j-i)/2;
if(nums[m]>target)
j = m-1;
else if(nums[m]<target)
i = m+1;
else
return m;
}
return i;
}
}
35. 搜索插入位置
最新推荐文章于 2024-11-12 10:59:16 发布