leetcode

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

2568.cpp (388B)


      1 class Solution {
      2   public:
      3     int minImpossibleOR(const vector<int> &nums) const {
      4         vector<bool> seen(32, false);
      5 
      6         for (const int n : nums) {
      7             if (__builtin_popcount(n) != 1) continue;
      8             seen[__builtin_ffs(n) - 1] = true;
      9         }
     10 
     11         for (int i = 0; i < 32; i++) {
     12             if (!seen[i]) return 1 << i;
     13         }
     14         return -1;
     15     }
     16 };