Simple Bitmask & Greedy
Complexity
Time complexity:
O(31*n) = O(n)
Space complexity:
cpp -> O(1)
java -> O(n)Code

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(31*n) = O(n)
---
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
cpp -> O(1)
java -> O(n)
----
# Code
```cpp []
class Solution {
public:
    vector<int> minBitwiseArray(vector<int>& nums) {
        for(int i=0; i<nums.size(); i++){
            if((nums[i]&1) == 0) {
                nums[i] = -1; continue;
            }
            int k=1;
            while((nums[i]& 1<<k) !=0) k++;
            nums[i] = nums[i]^(1<<(k-1));
        }
        return nums;
    }
};
```
```java []
class Solution {
    public int[] minBitwiseArray(List<Integer> nums) {
        int[] ans = new int [nums.size()]; 
        for(int i=0; i<nums.size(); i++){
            if((nums.get(i)&1) == 0) {
                ans[i] = -1; continue;
            }
            int k=1;
            while((nums.get(i)& 1<<k) != 0) k++;
            ans[i] = nums.get(i)^(1<<(k-1));
        }
        return ans;
    }
}
```
['Array', 'Greedy', 'Bit Manipulation', 'Bitmask', 'C++', 'Java']