Python3 || 11 lines, just odd numbers || T/S: 98% / 64%
Here\'s the intuition:\nThe prime number condition is a red herring. The real condition is the elements of nums are odd integers (excepting of course, 2). Odd n
Here\'s the intuition:\nThe *prime number* condition is a *red herring*. The real condition is the elements of `nums` are odd integers (excepting of course, 2). Odd numbers are either 4 mod 1 or 4 mod 3. The *4 mod 1* case becomes trivial after analyzing some examples. The *4 mod 3* case requires a bit more investigation, but does have an inuitive answer as well.\n```python3 []\nclass Solution:\n    def minBitwiseArray(self, nums):\n\n        def helper(num):\n\n            if  num %4 == 1:            # <-- 4 mod 1 case\n                return num - 1 \n\n            if num %4 == 3:             # <-- 4 mod 3 case\n                tmp = num\n                for i in range(num.bit_length()):\n                    tmp //= 2\n                    if not tmp%2: break\n                \n                return num - (1<<i)     \n\n            return -1                   # <-- just for num = 2\n\n\n        return map(helper,nums)\n```\n```cpp []\nclass Solution {\npublic:\n    std::vector<int> minBitwiseArray(const std::vector<int>& nums) {\n        std::vector<int> result;\n        \n        for (int num : nums) {\n            result.push_back(helper(num));\n        }\n        \n        return result;\n    }\n    \nprivate:\n    int helper(int num) {\n        if (num % 4 == 1) {  // Case when num % 4 == 1\n            return num - 1;\n        }\n        \n        if (num % 4 == 3) {  // Case when num % 4 == 3\n            int tmp = num;\n            for (int i = 0; i < (int)log2(num) + 1; ++i) {\n                tmp /= 2;\n                if (tmp % 2 == 0) {\n                    return num - (1 << i);\n                }\n            }\n        }\n\n        return -1;  // Special case for num == 2\n    }\n};\n\n```\n```java []\n\nclass Solution {\n    public int[] minBitwiseArray(List<Integer> nums) {\n        List<Integer> result = new ArrayList<>();\n        for (int num : nums) {\n            result.add(helper(num));}\n\n        int[] arrayResult = new int[result.size()];\n        for (int i = 0; i < result.size(); i++) {\n            arrayResult[i] = result.get(i);}\n        \n        return arrayResult;}\n\n    private int helper(int num) {\n        if (num % 4 == 1) {  // 4 mod 1 case\n            return num - 1;\n        }\n        if (num % 4 == 3) {  // 4 mod 3 case\n            int tmp = num;\n            int i = 0;\n            while (tmp > 0) {\n                tmp /= 2;\n                if (tmp % 2 == 0) break;\n                i++;}\n\n            return num - (1 << i);}\n        return -1;  // just for num = 2\n    }\n}\n```\n[https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii/submissions/1420215826/](https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii/submissions/1420215826/)\n\n\nI could be wrong, but I think that time complexity is *O*(*NB*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)` and *B* ~ average bit length the elements in `nums`.
['C++', 'Java', 'Python3']