Brilliant use of data structures you could have ever seen! 🎀
This is the first approach after brute force I came up with for this problem. Some times using nested data structures can come handy.\n\nTC: O(N x 32)\nSC: O(N 
*This is the first approach after brute force I came up with for this problem. Some times using nested data structures can come handy.*\n\n*TC: O(N x 32)*\n*SC: O(N x 32)\nwhere 1e5 >= N >= 0*\n\n```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        unordered_map<int, queue<int>>m;\n        \n        for(int i=0; i<n; ++i) {\n            int bit = 0;\n            int num = nums[i];\n            \n            while(num) {\n                if(num&1) {\n                    m[bit].push(i);\n                }\n                \n                num >>= 1;\n                ++bit;\n            }\n        }\n        \n        vector<int>ans;\n        \n        for(int i=0; i<n; ++i) {\n            int bit = 31;\n            int max_len = 1;\n            while(bit>=0) {\n                if(m.find(bit)!=m.end()) {\n                    while(!m[bit].empty() and m[bit].front()<i) {\n                        m[bit].pop();\n                    }\n                    if(m[bit].empty()) {\n                        m.erase(bit);\n                    } else {\n                        max_len = max(max_len, m[bit].front()-i+1);\n                    }\n                }\n                --bit;\n            }\n            ans.push_back(max_len);\n        }\n        \n        return ans;\n    }\n};\n```
['Bit Manipulation', 'Queue']