```
class Solution {
public:
int missingNumber(vector<int>& nums) {
const int len=nums.size();
int result=len;
for(int i=0;i<len;i++){
result=result^nums[i]^i;
}
return result;
}
};
```