C++ | Bit Solution
Code\n\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ans(n);\n        ve
# Code\n```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> ans(n);\n        vector<int> closestOne(32);\n        for(int i = n - 1; i >= 0; i--) {\n            for(int j = 0; j <= 31; j++) {\n                if(nums[i] & (1 << j))\n                    closestOne[j] = i;\n            }\n            ans[i] = max(1, *max_element(closestOne.begin(), closestOne.end()) - i + 1);\n        }\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'C++']