class Solution {
public:
int missingNumber(vector<int>& nums)
{
int n = nums.size();
for(int i = 0; i < nums.size(); i++)
{
n += i - nums[i];
}
return n;
}
};
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up