Beats 95% solutions
Complexity\n- Time complexity:O(N)\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
# Complexity\n- Time complexity:O(N)\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```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        vector<int> ans;\n        for(int i=0;i<nums.size();i++){\n            int num=nums[i];\n            int curr=0;\n            if(num==2)\n            {\n                ans.push_back(-1);\n                continue;\n            }\n            int check = 1;\n            for(int i = 0; i < 31; i++) {\n                if(((num & (1 << (i + 1))) == 0) && check == 1) {\n                    check = 0;  \n                } else {\n                    curr = curr + ((num & (1 << i)) ? (1 << i) : 0);\n                }\n            }\n\n            ans.push_back(curr);\n        }\n        return ans;\n    }\n};\n```
['C++']