思路分析
代码如下
public int missingNumber(int[] nums) {
int l = 0, r = nums.length - 1;
while (l <= r) {
int cent = (r + l) / 2;
if (nums[cent] > cent) // 左区间
r = cent - 1;
else // == 右区间
l = cent+1;
}
return r+1;
}
原文:https://www.cnblogs.com/duduwy/p/13390555.html