C++ solution
\nclass Solution\n{\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums)\n    {\n        std::vector<int> res(nums.size(), 1);\n        std::vector<in
```\nclass Solution\n{\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums)\n    {\n        std::vector<int> res(nums.size(), 1);\n        std::vector<int> mask(32, -1);\n\n        for (int i = nums.size() - 1; i >= 0; i--)\n        {\n            for (int imask = 0; imask < 32; imask++)\n            {\n                if (nums[i] & (1 << imask))\n                {\n                    mask[imask] = i;\n                }\n            }\n\n            int ifar = i;\n            for (int imask = 0; imask < 32; imask++)\n            {\n                if (mask[imask] != -1)\n                {\n                    ifar = std::max(ifar, mask[imask]);\n                }\n            }\n\n            res[i] = ifar - i + 1;\n        }\n\n        return res;\n    }\n};\n```
['C++']