Simple 6 liner | Beats 88% users | C++ | Python
Intuition\nYou are given a list of integers nums and need to find the smallest power of 2 that is not present in the list. Powers of 2 are numbers like 1 (2^0),
# Intuition\nYou are given a list of integers `nums` and need to find the smallest power of 2 that is not present in the list. Powers of 2 are numbers like 1 (2^0), 2 (2^1), 4 (2^2), 8 (2^3), etc. This problem can be viewed as finding the "missing" smallest power of 2 in the provided list.\n\n# Approach\n1. Iterate Through Powers of 2: Start from 2^0 and move upwards, checking each power of 2.\n2. Check Presence in List: For each power of 2, check if it is present in the list `nums`.\n3. Return the First Missing Power: The first power of 2 that is not found in the list is the result.\nThis approach ensures that you find the smallest missing power of 2 efficiently.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code for C++\n```\nclass Solution {\npublic:\n    int minImpossibleOR(vector<int>& nums) {\n        \n        for(int i=0; i<pow(2,31); i++){\n            int a = pow(2,i);\n            auto it = find(nums.begin(), nums.end(), a);\n            if(it != nums.end()){\n                continue;\n            }else{\n                return a;\n            }\n        }\n        return 0;\n    }\n};\n```\n# Code for Python\n```\nclass Solution:\n    def minImpossibleOR(self, nums):\n        for i in range(32):  # Using 32 to cover up to 2^31\n            a = pow(2, i)\n            if a in nums:\n                continue\n            else:\n                return a\n        return 0\n```\n
['C++']