intsingleNumber2(int* nums, int numsSize) { int sum1 = 0; for (int i = 0; i < numsSize; i++) { sum1 += nums[i]; } for (int i = 0; i < numsSize; i++) { for (int j = i+1; j < numsSize; j++) { if (nums[i] = nums[j]) { for (int n = j; n < numsSize; n++) { nums[n] = nums[n + 1]; } numsSize--; } } } int sum2 = 0; for (int i = 0; i < numsSize; i++) { sum2 += nums[i]; } return (sum2 * 3 - sum1)/2;
} /*********************************************************/ intsingleNumber2(int* nums, int numsSize) { int ans = 0; for (int i = 0; i < 32; ++i) { int total = 0; for (int j = 0; j < numsSize; ++j) { total += ((nums[j] >> i) & 1); } if (total % 3) { ans |= (1u << i); } } return ans; }