[Python] find the largest distance for each bit of the maximum OR value
\nclass Solution:\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\n        # two sweeps\n        len_n = len(nums)\n        # sweep 1: find the 
```\nclass Solution:\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\n        # two sweeps\n        len_n = len(nums)\n        # sweep 1: find the maximum OR value at each index\n        max_or = [0] * len_n\n        idx, c_or = len_n - 1, 0\n        while idx >= 0:\n            c_or |= nums[idx]\n            max_or[idx] = c_or\n            idx -= 1\n        \n        # sweep 2: starting from the last number, track the closest index for every bit\n        ans = [1] * len_n\n        bidx = [None] * 32\n        idx = len_n - 1\n        while idx >= 0:\n            i = 0\n            n = nums[idx]\n            while n:\n                if n & 1:\n                    bidx[i] = idx\n                i += 1\n                n >>= 1\n            mor = max_or[idx]\n            max_dist, i = 1, 0\n            while mor:\n                if mor & 1:\n                    max_dist = max(max_dist, bidx[i] - idx + 1)\n                i += 1\n                mor >>= 1\n            ans[idx] = max_dist\n            idx -= 1\n            \n        return ans\n```
['Python3']