```
class Solution {
public:
int missingNumber(vector<int>& nums) {
int x = 0;
for(int num: nums) x = x ^ num;
switch(nums.size()&3) {
case 2:
return x^1^nums.size();
case 0:
return x^nums.size();
case 1:
return x^1;
case 3:
return x;
}
}
};
```