We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ca73e5 commit a67b79cCopy full SHA for a67b79c
1 file changed
C++/single-number-iii.cpp
@@ -6,6 +6,7 @@ class Solution {
6
vector<int> singleNumber(vector<int>& nums) {
7
// Xor all the elements to get x ^ y.
8
int x_xor_y = accumulate(nums.cbegin(), nums.cend(), 0, bit_xor<int>());
9
+
10
// Get the last bit where 1 occurs.
11
x_xor_y &= -x_xor_y;
12
0 commit comments