C++ , Easy and precise , Sliding Window solution with BIT_COUNT,
Intuition\n. \n\n\n# Approach\n Describe your approach to solving the problem. \n\nCreate a bit_vec (Vector) that stores tha count of bits that found till now\n
# Intuition\n<!--. -->\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nCreate a bit_vec (Vector) that stores tha count of bits that found till now\n\nExample\n\nn= [1,1,2,2,3,3]  max_or = 3\n    i=0,j=0;\n\nbit_vec[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0......32 times }\n\nnext\nn = [1,1,2,2,3,3]  \n     i=0, j =2   at this position we found or = 3 so increment i\n\nbit_vec[] = { 2 ,1, 0 ,0 ,0 ,0 ,0  .... 32 times}\n\nn = [1,1,2,2,3,3]\nres [3,0,0,0,0,0]\n      i=1, j=2 still the or is => \'3\' so increment the i\nbit_vec[]= { 1,1,0,0,0,0,.... 32 times};\n\nnotice how bit_vec[0] changes from 2-1 becuse , as the i incremented we need to decrement the count of bits from the bit_vec;\n\nand if j reached the end bit i has not the recursively call the same fucntion\n\nPlease upvote the solution if you found helpful it helps me keep motivated\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\nO(32*N) not sure (please suggest as not sure about how many time reursion can go)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\nO(N) => for result vector\n\n# Code\n```\nclass Solution {\npublic:\n\n    int getOR(vector<int> &bit_vec)  // to convet the bit_vec into number  example bit_vec[] = {2,3,4, 0 ,0,0,} => 7 as first 3 bits are set\n    {\n        int ans  =0;\n        for(int i =0 ; i<32 ; i++)\n          if(bit_vec[i] >0)\n               ans = ans | (1<<i);   \n        return ans;\n    }\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        \n        vector<int> bit_vec(32,0);\n        vector<int> res((int)nums.size(), 1);\n\n        int OR =0;\n\n        for(int &i : nums)\n        OR = OR |i;\n\n        int j =0 , i =0;\n\n        for(j =0 ;j< nums.size(); ++j)\n        {\n            int a = nums[j];\n            int k =0;\n            while(a) // add bit count of current numebr to vector\n            {\n                if(a & 1)\n                bit_vec[k]++;\n                a >>=1;\n                ++k;\n            }\n\n            while(i <=j and getOR(bit_vec) >= OR) // increment i uthil there is maximum or\n            {\n                res[i] = j-i+1;\n                \n                a= nums[i]; k=0;\n                while(a) // remove the bit count from vector\n                {\n                    if(a & 1)\n                    bit_vec[k]--;\n                    a >>=1;\n                    ++k;\n                }\n                i++;\n            }\n        }\n        if(i< nums.size()) // if i is still less than nums size then recursively call the function \n        {\n            vector<int> t(nums.begin()+i,nums.end());\n            auto v = smallestSubarrays( t);\n\n            for(int k = i ;k< nums.size() ; k++)\n              res[k] =v[k-i];\n        }\n\n        return res;\n    }\n};\n```
['C++']