Tracking first occurrence of each set bit
\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        vector<set<int>> bits_occurances(32);\n        for(int i=0;i<32;i++
```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        vector<set<int>> bits_occurances(32);\n        for(int i=0;i<32;i++){\n            for(int j=0;j<nums.size();j++){\n                if(nums[j] & (1<<i)) bits_occurances[i].insert(j);\n            }\n        }\n        int n=nums.size();\n        vector<int> ans(n,1);\n        for(int i=0;i<n;i++){\n            for(int j=0;j<32;j++){\n                if(bits_occurances[j].size()>0){\n                    auto it=bits_occurances[j].begin();\n                    ans[i]= max(ans[i],(*it) - i +1);\n                    if(*it==i) bits_occurances[j].erase(it);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'Ordered Set']