C++ Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\nLet num is any number in array.\n\n1) if num is in the form of x0 -> even -> -1(not p
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nLet num is any number in array.\n\n1) if num is in the form of x0 -> even -> -1(not possible use pen and paper to check since adding 1 is always a odd number).\n2) only even prime number is 2 thus -1 for 2\n3) odd prime have 2 form\n4) form 1 -> x01 , form 2 xA\'1\n    \n    x -> any bits 0/1\n    A -> count of continous bits , in above case count of conti. 1 bit\n\n5) for form 1 easy -> num - 1 (use pen and paper to check)\n6) for form 2 medium -> x111 - > x011 (again use pen and paper to check)\n7) Do lot\'s of dry run to check then see my code for building correct mask to solve.\n\nGood Luck :) \nIf any doubt pin me on "partharora3350@gmail.com" for discussion on google meet.\n\n\n# Code\n```cpp []\nclass Solution\n{\npublic:\n    vector<int> minBitwiseArray(vector<int> &a)\n    {\n        int n = a.size();\n        vector<int> res(n);\n        for(int i = 0 ; i < n; i++){\n            int num = a[i];\n            if(num == 2) res[i] = -1;\n            else if((num & 3) == 1) res[i] = num - 1;\n            else{\n                int mask = 1;\n                while((mask & num)){\n                    mask <<= 1;\n                }\n                mask >>= 1;\n                mask = ~mask;\n                num &= mask;\n                res[i] = num;\n            }\n        }\n        return res;\n    }\n};\n```
['C++']