Simple Map and Set that's it
\n// well idea to keep track of all the index array where \n// jth bit( where j is from 0 to 30)  is set\n// now while traversing through the array\n// just che
```\n// well idea to keep track of all the index array where \n// jth bit( where j is from 0 to 30)  is set\n// now while traversing through the array\n// just check if jth bit is 0 if yes then find the next\n// closest index where jth bit is 1\n// similary check from all jth bits(0-30)\n// and out of all furthest is our answer\n// if jth bit is already 1 then we don\'t need to do anything\n\n vector<int> smallestSubarrays(vector<int>& nums) \n    {\n        vector<int>bits(32,0);\n        int n = nums.size();\n        vector<int>ans;\n        map<int,int> mp;\n        map<int,set<int>> mset;\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<31;j++)\n            {\n                if(nums[i]&((int)pow(2,j)))\n                {\n                    mp[j]++;\n                    mset[j].insert(i);\n                }\n            }\n        }\n        \n        \n        for(int i=0;i<n;i++)\n        {\n            int idx =i;\n            for(int j=30;j>=0;j--)\n            {\n                if(mp.find(j)!=mp.end() && (nums[i]&((int)pow(2,j)))==0)\n                    idx = max(idx,*(mset[j].begin()));\n                \n                else if(nums[i]&((int)pow(2,j)))\n                    mset[j].erase(i);\n                \n            }\n            ans.push_back(idx-i+1);\n        }\n        \n        return ans;\n    }\n```
['Ordered Set']