Solution 1
- TimeO(n)
- SpaceO(1)
where, n is length of nums
DID NOT GO THROUGH THE SOLUTION YET!
Python · 2026-01-21
class Solution:
'''
Time Complexity: O(n)
Space Complexity: O(1)
where, n is length of nums
DID NOT GO THROUGH THE SOLUTION YET!
'''
def minBitwiseArray(self, nums: List[int]) -> List[int]:
ans = []
for n in nums:
if n % 2 == 0:
ans.append(-1)
continue
t = 0
temp = n
while temp & 1:
t += 1
temp >>= 1
ans.append(n - (1 << (t - 1)))
return ans