Using vector | in 32*O(n) time complexity | O(n) SC
Intuition \n Describe your first thoughts on how to solve this problem. \nWe can count bits of every num in nums in a vector.\n\n# Approach \n Describe your app
## Intuition \n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can count bits of every num in nums in a vector.\n\n# Approach \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: 32 * O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n\nint f1(vector<int> &v,int x){\n    int cntor = 0;\n    for(int i = 0;i<32;i++){\n        if(x & (1<<i)) v[i]++;\n    }\n    for(int i = 0;i<32;i++) {\n        if(v[i]>0) cntor |= (1<<i);\n    }\n    return cntor;\n}\n\nint f2(vector<int> &v,int x){\n    int cntor = 0;\n    for(int i = 0;i<32;i++){\n        if(x & (1<<i)) v[i]--;\n    }\n    for(int i = 0;i<32;i++) {\n        if(v[i]>0) cntor |= (1<<i);\n    }\n    return cntor;\n}\n\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        if(n==1) return {1};\n        vector<int>ans(n,1);\n        vector<int> arr(n);\n        arr[n-1] = nums[n-1];\n        for(int i = n-2;i>=0;i--){\n            arr[i] = arr[i+1] | nums[i];\n        }\n        for(int i = 0;i<n;i++){\n            cout<<arr[i]<<" ";\n        }\n\n        int maxor = 0;\n        for(int n : nums) maxor = maxor | n;\n        int i = 0,j = 0;\n        int cntor = 0;\n        vector<int> v(32,0);\n        while(i<n){\n\n            while(j<n){\n                if(cntor == arr[i]) {\n                    \n                    break;\n                }\n                cntor = f1(v,nums[j]);\n                j++;\n            }\n            ans[i] = j-i;\n            if(arr[i]==0 ) ans[i] = 1;\n            cntor = f2(v,nums[i]);\n\n            i++;\n        }\n        return ans;\n    }\n};\n```
['C++']