Bit Before Leftmost Zero
There is no answer for an even number. \n\nFor an odd number n, there is always an answer: n - 1 (since (n - 1) | n == n).\n\nHowever, there could be other answ
There is no answer for an even number. \n\nFor an odd number `n`, there is always an answer: `n - 1` (since `(n - 1) | n == n`).\n\nHowever, there could be other answers, such as `n - 2`, `n - 4`, `n - 8` and so on.\n\nTo find the minimum answer, let\'s look at example `111` (`0b1101111`):\n- `0b1101111 - 0b0001`; `0b1101110 | 0b1101111 == 0b1101111`\n- `0b1101111 - 0b0010`; `0b1101101 | 0b1101110 == 0b1101111`\n- `0b1101111 - 0b0100`, `0b1101011 | 0b1101100 == 0b1101111`\n- `0b1101111 - 0b1000`, `0b1100111 | 0b1101000 == 0b1101111`\n\t- This will not work for `0b10000` as it will flip a zero bit, so the OR result won\'t be equal to `n`.\n\nAs you can see, the smallest answer can be achieved by removing a bit before the leftmost zero.\n\n**C++**\n```cpp\nvector<int> minBitwiseArray(vector<int>& nums) {\n    vector<int> res;\n    for (int n : nums) {\n        if (n % 2) {\n            int bit = 1;\n            for (int x = n; x & 2; x >>= 1)\n                bit <<= 1;\n            res.push_back(n ^ bit);            \n        }\n        else\n            res.push_back(-1);\n    }\n    return res;\n}\n```
[]