https://www.acwing.com/problem/content/64/
思路:
class Solution {
public:
int getMissingNumber(vector<int>& nums) {
int l = 0,r = nums.size();
if(r == 0){
return 0;
}
int ans = 0;
//二分查找第一个nums[i]!=i的下标
while(l < r){
int mid = (l + r) >> 1;
if(nums[mid] == mid){
l = mid + 1;
}
else {
r = mid;
}
}
return l;
}
};