-
-
Notifications
You must be signed in to change notification settings - Fork 299
/
136.cpp
32 lines (30 loc) · 815 Bytes
/
136.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
__________________________________________________________________________________________________
8ms
int optimization = []() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
return 0;
}();
class Solution {
public:
int singleNumber(vector<int>& nums) {
int ans = 0;
for (int n : nums) {
ans ^= n;
}
return ans;
}
};
__________________________________________________________________________________________________
9416 kb
class Solution {
public:
int singleNumber(vector<int>& nums) {
int result = 0;
for(int i = 0; i < nums.size(); i++){
result ^= nums[i];
}
return result;
}
};
__________________________________________________________________________________________________