Optimal C++ Solution Beats 100%
Code\ncpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int> &nums) {\n        int n = nums.size();\n        vector<int> ans(n);\n\n    
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int> &nums) {\n        int n = nums.size();\n        vector<int> ans(n);\n\n        for(int i = 0; i < n; ++i) {\n            if(nums[i] == 2) {\n                ans[i] = -1;\n                continue;\n            }\n\n            int mask = 1;\n            while(nums[i] & mask)\n                mask <<= 1;\n            \n            mask >>= 1;\n            ans[i] = nums[i] & ~mask;\n        }\n\n        return ans;\n    }\n};\n```
['C++']