leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0260.cpp (321B)


      1 class Solution {
      2   public:
      3     vector<int> singleNumber(const vector<int> &nums) {
      4         long long diff = accumulate(begin(nums), end(nums), 0, bit_xor<int>());
      5         diff &= -diff;
      6         vector<int> res = {0, 0};
      7         for (const int n : nums)
      8             res[(n & diff) == 0] ^= n;
      9         return res;
     10     }
     11 };