Python. Closest bit
\nclass Solution:\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\n        def get_bits(x):\n            index = 0\n            while x > 0:\n  
```\nclass Solution:\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\n        def get_bits(x):\n            index = 0\n            while x > 0:\n                if x & 1:\n                    yield index\n                index += 1\n                x >>= 1\n                \n        nums_len = len(nums)\n        last_bit_index = [nums_len] * 31\n        result = [1] * nums_len\n        cur_bits = set()\n        for index in range(nums_len - 1, -1, -1):\n            x = nums[index]\n            x_bits = list(get_bits(x))\n            for b in x_bits:\n                last_bit_index[b] = index + 1\n            cur_bits.update(x_bits)\n            for b in cur_bits:\n                result[index] = max(result[index], last_bit_index[b] - index)\n                \n        return result\n            \n            \n```
[]