C++ || Operation on each bit
\n\n# Code\n\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int orr=0;\n        int n=nums.size();\n        vector<
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int orr=0;\n        int n=nums.size();\n        vector<int>val(n,0);\n        for(int i=n-1;i>=0;i--)\n        {\n            orr=orr|nums[i];\n            val[i]=orr;\n        }\n        vector<int>ans;\n        map<int,set<int>>bits;\n        for(int i=0;i<n;i++)\n        {    \n           \n            for(int j=0;j<32;j++)\n            {   \n                \n                if(((nums[i])&(1<<j)))\n                {   \n                    bits[j].insert(i);\n                }\n            }\n        }\n   \n        for(int i=0;i<nums.size();i++)\n        {\n            int maxxbit=val[i];\n            int len=-1e9;\n            for(int j=0;j<32;j++)\n            {\n                if((maxxbit&(1<<j)))\n                {\n                    auto it=bits[j].lower_bound(i);\n                    int idx=*it;\n                    len=max(len,idx-i+1);\n                }\n            }\n            if(len==-1e9) ans.push_back(1);\n            else\n            ans.push_back(len);                \n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'Bit Manipulation', 'C++']