O(n) Binary Search + bit manipulation solution
\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& v) {\n        unordered_map<int,vector<int>> mp;\n        for(int i=0 ; i<v.size() ;
```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& v) {\n        unordered_map<int,vector<int>> mp;\n        for(int i=0 ; i<v.size() ; ++i) {\n            for(int j=0 ; j<31 ; ++j) {\n                if(v[i]&(1<<j)) {\n                    mp[j].push_back(i);\n                }\n            }\n        }\n        vector<int> ans(v.size());\n        for(int i=0 ; i<v.size() ; ++i) {\n            int mx=i;\n            for(int j=0 ; j<31 ; ++j) {\n                auto len = lower_bound(begin(mp[j]), end(mp[j]), i);\n                if(len != mp[j].end()) {\n                    mx = max(mx, *len);\n                }\n            }\n            ans[i] = mx-i+1;\n        }\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'Binary Tree']