message: Update single-number-iii.cpp
diff: @@ -5,7 +5,7 @@ class Solution {
  public:
  vector<int> singleNumber(vector<int>& nums) {
  // Xor all the elements to get x ^ y.
  - const auto x_xor_y = accumulate(nums.cbegin(), nums.cend(), 0, bit_xor<int>());
  + const auto x_xor_y = accumulate(nums.cbegin(), nums.cend(), 0u, bit_xor<int>());
  // Get the last bit where 1 occurs by "x & ~(x - 1)"
  // Because -(x - 1) = ~(x - 1) + 1 <=> -x = ~(x - 1)
  @@ -23,11 +23,13 @@ public:
  }
  };
  +// Time: O(n)
  +// Space: O(1)
  class Solution2 {
  public:
  vector<int> singleNumber(vector<int>& nums) {
  // Xor all the elements to get x ^ y.
  - int x_xor_y = 0;
  + uint32_t x_xor_y = 0;
  for (const auto& i : nums) {
  x_xor_y ^= i;
  }
  @@ -38,13 +40,13 @@ public:
  // Get the subset of A where the number has the bit.
  // The subset only contains one of the two integers, call it x.
  // Xor all the elements in the subset to get x.
  - int x = 0;
  + uint32_t x = 0;
  for (const auto& i : nums) {
  if (i & bit) {
  x ^= i;
  }
  }
  - return {x, x_xor_y ^ x};
  + return {int(x), int(x_xor_y ^ x)};
  }
  };
  