O(n) Solution: Smallest Power of Two
Intuition\n Describe your first thoughts on how to solve this problem. \n answer: we have to find smallest power of 2 element in the array\n reason:\n1) lets sa
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* answer: we have to find smallest power of 2 element in the array\n* reason:\n1) lets say I have 1,2,4....2^i elements present in the array.\n2) therefore I can make all the elements upto 2^(i+1)-1  using simple or operation.\n3) but I cannot make 2^(i+1)th element.\n4) Therefore we have to find the smallest power of 2 element that is not present in the array.\n    \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1) Since the only possible solutions can be 1,2,4,8\n2) put all the elements in an unordered_set \n3) and check smallest power of two that does not exist\n# Complexity\n- Time complexity: O(n) to store all elements in the array\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minImpossibleOR(vector<int>& nums) \n    {\n        unordered_set<long long>s(begin(nums),end(nums));\n        for(int i=0;i<=32;i++)\n        {\n            long long num=(1<<i);\n            if(s.find(num)==s.end())\n                return num;\n        }\n        return -1;\n    }\n};\n```
['C++']