Skip to content

Commit f6345c1

Browse files
committed
Create single-number.cpp
1 parent df4b192 commit f6345c1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

C++/single-number.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int singleNumber(vector<int>& nums) {
7+
return accumulate(nums.cbegin(), nums.cend(),
8+
0, std::bit_xor<int>());
9+
}
10+
};

0 commit comments

Comments
 (0)