Simple pattern based O(N) solution. Brute force is not needed.
IntuitionThe pattern is as follows:
'2' is the only prime number and hence, the result is -1
All other prime numbers apart from 2 are odd numbers i.e the lowest
# Intuition

The pattern is as follows:

1. '2' is the only prime number and hence, the result is -1
2. All other prime numbers apart from 2 are odd numbers i.e the lowest bit is set.
3. The trivial ans is (num-1), but the question says to find the lowest possible answer.
4. Hence, we need to find the lowest one bit after the lowest zero bit and turn it off.
5. We need to turn it off because when we add 1, the carry of 1 will basically sit in the turned-off position.

# Approach
<!-- Describe your approach to solving the problem. -->

1. For every number, do the following
   1. right shift the number until a zero is found in the lowest bit
   2. increment a counter by 1
2. Now the counter says the number of bits until we find the lowest zeroth bit.
3. Now turn off the first one bit after the zeroth bit i.e num ^ (1 << (onebits -1));

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

TC - O(n)
Max we can go is 32 bit and the constraints are small.

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
SC - O(n)

# Code
```java []
class Solution {
    public int[] minBitwiseArray(List<Integer> nums) {
        int n = nums.size();
        int[] ans = new int[n];
        int i=0;
        for(int num: nums){
            if(num == 2){
                ans[i++] = -1;
                continue;
            }
            int n1=num, onebits = 0;
            while((n1 & 1) != 0){
                onebits++;
                n1>>=1;
            }
            ans[i++] = num ^ (1<< (onebits-1));
        }
        return ans;
    }
}
```
['Java']