1 class Solution {
2 public:
3 int singleNumber(
int A[],
int n) {
4 // Note: The Solution object is instantiated only once and is reused by each test case.
5 if (n ==
0)
return 0;
6
7 int bit[
32];
8 int result =
0;
9
10 for (
int i =
0; i <
32; i++
){
11
12 bit[i] =
0;
13 for (
int j =
0; j < n; j++
){
14
15 if ((A[j] >> i) &
1) bit[i] = (bit[i] +
1) %
3;
16 }
17 result += (bit[i]<<
i);
18 }
19 return result;
20 }
21 };
转载于:https://www.cnblogs.com/tanghulu321/p/3390474.html
转载请注明原文地址: https://win8.8miu.com/read-1553732.html