leetcode

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

0137.cpp (263B)


      1 class Solution {
      2   public:
      3     int singleNumber(const vector<int> &nums) {
      4         int mask1 = 0, mask2 = 0;
      5         for (int n : nums) {
      6             mask1 = (mask1 ^ n) & ~mask2;
      7             mask2 = (mask2 ^ n) & ~mask1;
      8         }
      9         return mask1;
     10     }
     11 };