Easy C++ Solution | Most Basic Approach
Code\n\nclass Solution {\npublic:\n    bool canRemove(vector<int>& bits, int numberToInsert){\n        vector<int> bitValues(32, 0);\n        add(bitValues, num
# Code\n```\nclass Solution {\npublic:\n    bool canRemove(vector<int>& bits, int numberToInsert){\n        vector<int> bitValues(32, 0);\n        add(bitValues, numberToInsert);\n\n        for(int i=0; i<32; i++){\n            if(bits[i] > 0 && bits[i] - bitValues[i] == 0)  return false;\n        }\n        for(int i=0; i<32; i++) bits[i] = max(0, bits[i] - bitValues[i]);\n        return true;\n    }\n    void add(vector<int>& bits, int number){    //add Bit Value of new element:\n        int bitPos = 0;\n        while(number > 0){\n            if(number&1)    bits[bitPos]++;\n            number = number>>1;\n            bitPos++;\n        }\n    }\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        vector<int> ans(nums.size(), -1);\n\n        queue<int> q;\n        vector<int> bits(32,0);\n        for(int i=nums.size()-1; i>=0; i--){\n            q.push(nums[i]);\n\n            add(bits, nums[i]);\n            while(!q.empty() && canRemove(bits, q.front())) q.pop();\n            ans[i] = q.size() == 0 ? 1 : q.size();\n        }\n\n        return ans;\n    }\n};\n```
['C++']