We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent df4b192 commit f6345c1Copy full SHA for f6345c1
C++/single-number.cpp
@@ -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