47 ms Beats 97.69% | Easy Bitmask Solution
Complexity\n- Time complexity: O(10n)\n\n- Space complexity: O(n)\n\n# Code\npython3 []\nclass Solution:\n    def __init__(self):\n        # n <= 1000 < 1024 ==
# Complexity\n- Time complexity: $$O(10n)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```python3 []\nclass Solution:\n    def __init__(self):\n        # n <= 1000 < 1024 == 2 ** 10\n        self.masks = [0x0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff]\n\n    def minBitwiseArray(self, nums: List[int]) -> List[int]:\n        ans = [-1] * len(nums)\n\n        for i, x in enumerate(nums):\n            if x == 2:\n                continue\n            for j in range(1, 10):\n                if x & self.masks[j] and not x & (self.masks[j + 1] - self.masks[j]):\n                    ans[i] = x - (self.masks[j] - self.masks[j - 1])\n                    break\n\n        return ans\n```
['Python3']