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