Bit solution
Code
# Code
```cpp []
class Solution {
public:
    vector<int> smallestSubarrays(vector<int>& nums) {
        int n = nums.size();
        vector<int> last(32, -1);  // Last seen position of each bit
        vector<int> ans(n);

        for (int i = n - 1; i >= 0; --i) {
            // Update the last seen positions for bits set in nums[i]
            for (int b = 0; b < 32; ++b) {
                if (nums[i] & (1 << b)) {
                    last[b] = i;
                }
            }

            // Find the furthest index we need to include to match OR
            int furthest = i;
            for (int b = 0; b < 32; ++b) {
                if (last[b] != -1) {
                    furthest = max(furthest, last[b]);
                }
            }

            ans[i] = furthest - i + 1;
        }

        return ans;
    }
};

```
['C++']