Beats 100% using bit manipulation
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def minBitwiseArray(self, nums: List[int]) -> List[int]:\n\n        # intuition is take the num and unset the leftmost bit untill u reach the 0\n\n        # in the sense 1 0 0 1 1 here unset the 1 at position 2 from right\n        # ie           1 0 0 0 1  and add +1 to this value and do OR between the two\n\n        def fn(num):\n            # traverse through the 32 bit number store the last_set_bit\n            last_set_bit = 0\n            for i in range(32):\n                if num & (1 << i):\n                    last_set_bit = i\n                else:\n                    break\n\n                mask = (1 << last_set_bit)\n                mask = ~mask & num\n            return mask \n\n        ans = []\n        for num in nums:\n\n            if num == 2:\n                ans.append(-1)\n                continue\n            temp = fn(num)\n            ans.append(temp)\n        return ans\n        \n```
['Python3']