Python3.  O( n ). Backtracking, Update SET bits
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    \nSwitch bits one
# 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    \nSwitch **bits** one by one and **check** if it\'s valid \n    \n    Ex: 10111\n\n    10110 check ( 10110 | (10110 - 1) == 10111?) no? go next, else return\n    10101 check \n    10011 check \n    so on. \n\n##### Logic:\n\n    Any string can be a 32 bit number\n    \n    Go bit by bit removing only one bit and check if update `number OR number + 1` can give the target  *\n\nhope helps.\n\n#### UPDATED:\n\nWe can modify string manipulation with bit manipulation:\n\n```\n        tmp = 0\n            while i >= (1 << tmp):\n                # print(tmp, i, 1 << tmp, 1 & (1 << tmp))\n                if i & (1 << tmp) :\n                    tm = i ^ (1 << tmp)\n                    if tm | (tm + 1) == i:\n\n                        mn = min(mn, tm)\n                tmp = tmp + 1\n```\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        # 1.\n        ans = []\n        for i in nums:\n            tmp = bin(i).replace("0b", "")\n            mn = inf\n            for j in range(len(tmp)):\n\n                if tmp[j] == "1":\n\n                    tm = int(tmp[:j] + "0" + tmp[j + 1:], 2)\n  \n                    if tm | (tm + 1) == i:\n\n                        mn = min(mn, tm)\n\n            ans.append(mn if mn != inf else -1)\n\n        return ans \n```\n\n        # UPDATED. Same logic but with bits: Check if bit is set:\n\n        # 2.\n        ans = []\n        for i in nums:\n            mn = inf\n            tmp = 0\n            while i >= (1 << tmp):\n\n                if i & (1 << tmp) :\n\n                    tm = i ^ (1 << tmp)\n\n                    if tm | (tm + 1) == i:\n\n                        mn = min(mn, tm)\n                        \n                tmp = tmp + 1\n\n            ans.append(mn if mn != inf else -1)\n\n        return ans\n\nTLE:\n``` \n        # ans = []\n        # for n in nums:\n        #     flag = True\n        #     for i in range((n // 2) - 1, n, 1):\n        #         if i | i + 1 == n:\n        #             ans.append(i)\n        #             flag = False\n        #             break\n        #     if flag:\n        #         ans.append(-1)\n\n        # # print(ans)\n        # return ans\n        \n        \n```
['Python3']