I tried the XOR method also but this one is simple and I think easier (maybe not better) to understand. Basically if you want to count every number from 1 to 100 you use the formula n * (n+1)/2. So What I did is sum the values in the vector and subtract that sum from the formula I stated based on nums.size().

```
int missingNumber(vector<int>& nums)
{
int sum = 0;
for(auto i : nums)
sum += i;
return nums.size() * (nums.size() + 1) / 2 - sum;
}
```