class Solution {
public:
int getMissingNumber(vector<int>& nums) {
if (nums.empty()) {
return 0;
}
int l = 0, r = nums.size() - 1;
while (l < r) {
int mid = l + r >> 1;
if (nums[mid] == mid) {
l = mid + 1;
} else {
r = mid;
}
}
if (nums[r] == r) {
return nums.size();
}
return r;
}
};