C++ | Bit Operation | No binary search
\nclass Solution {\npublic:\n    void dec2bin(int n, vector<int>& binbits) {\n        for (int i = 0; i < 30; i++) {\n            binbits[i] = n % 2;\n         
```\nclass Solution {\npublic:\n    void dec2bin(int n, vector<int>& binbits) {\n        for (int i = 0; i < 30; i++) {\n            binbits[i] = n % 2;\n            n /= 2;\n        }\n    }\n    \n    vector<int> smallestSubarrays(vector<int>& nums) {\n        vector<deque<int>> contibutes(30);\n        vector<int> ans(nums.size());\n        vector<int> binbits(30);\n        for (int i = 0; i < nums.size(); i++) {\n            dec2bin(nums[i], binbits);\n            for (int j = 0; j < 30; j++) \n                if (binbits[j] == 1) contibutes[j].push_back(i);\n        }\n        \n        for (int i = 0; i < nums.size(); i++) {\n            vector<int> onesIdx;\n            for (int i = 0; i < 30; i++) if (contibutes[i].size()) onesIdx.push_back(i);\n            int tmax = -1;\n            for (int& idx : onesIdx) tmax = max(tmax, contibutes[idx][0]);\n            ans[i] = max(tmax-i+1, 1);\n            for (int j = 0; j < 30; j++) if (contibutes[j][0] == i) contibutes[j].pop_front();\n\n        }\n        \n        return ans;\n    }\n};\n```
['Bit Manipulation', 'C']