Dashboard Temp Share Shortlinks Frames API

HTMLify

construct-the-minimum-bitwise-array-i.py
Views: 6 | Author: prakhardoneria
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Solution:
    def minBitwiseArray(self, nums: List[int]) -> List[int]:
        ans = []
        for x in nums:
            found = -1
            for a in range(x + 1):
                if (a | (a + 1)) == x:
                    found = a
                    break
            ans.append(found)
        return ans