Skip to content

Commit 2b5419b

Browse files
committed
136题的解
1 parent fc92f14 commit 2b5419b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cpp/136.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <vector>
2+
using std::vector;
3+
4+
class Solution {
5+
public:
6+
int singleNumber(vector<int>& nums) {
7+
/**
8+
* 1. Runtime: 12 ms, faster than 93.87% of C++ online submissions for Single Number.
9+
* 2. Memory Usage: 8.9 MB, less than 100.00% of C++ online submissions for Single Number.
10+
*/
11+
12+
int res = nums[0];
13+
int n = nums.size();
14+
for (int i = 1; i < n; ++i)
15+
res ^= nums[i];
16+
return res;
17+
}
18+
};

0 commit comments

Comments
 (0)