题目描述
blablabla
C++ 代码
class Solution {
public:
int getMissingNumber(vector<int>& nums) {
if (nums.empty()) return 0;
int l = 0, r = nums.size() - 1 ;
if (nums[0] != 0) return 0;
while(l < r) {
int mid = l + r + 1>> 1;
if (nums[mid] == mid) l = mid;
else r = mid - 1;
}
return l + 1;
}
};