```
class Solution {
public:
int singleNumber(vector<int>& nums) {
return accumulate(begin(nums),end(nums),0,bit_xor<int>());
}
};
```

Uses `accumulate`

to `fold`

or `reduce`

the array by applying a binary function which in this case is `bit_xor`

and `accumulates`

it to starting variable having value `0`

.