[C++] Set the bit before the rightmost zero to zero with xor.
\ncpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ans;\n\n        for
\n```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ans;\n\n        for (auto p : nums) {\n            if (p % 2 == 0) {\n                ans.push_back(-1);\n            } else {\n                for (int i = 1; i < 31; ++i) {\n                    if ((p & (1 << i)) == 0) {\n                        p = p ^ (1 << (i - 1));\n                        break;\n                    }\n                }\n                ans.push_back(p);\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']