2411. Smallest Subarrays With Maximum Bitwise OR
IntuitionDO ITApproachstick to BF forget opti for now!Complexity
Time complexity:O(n * 32)

Space complexity:o(32)
Code
# Intuition
DO IT
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
stick to BF forget opti for now!
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(n * 32)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:o(32)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def smallestSubarrays(self, nums: List[int]) -> List[int]:
        n = len(nums)
        last = [0] * 32  # Store last occurrence of each bit
        ans = [1] * n    # Initialize with minimum possible length
        
        # Process from right to left
        for i in range(n - 1, -1, -1):
            # Update last occurrence for current number's bits
            for j in range(32):
                if nums[i] & (1 << j):
                    last[j] = i
            
            # For current position, extend to rightmost bit needed
            max_last = i
            for j in range(32):
                max_last = max(max_last, last[j])
            ans[i] = max_last - i + 1
            
        return ans
```
['Python3']