C++ || Bitwise Sliding Window
# Intuition\nThe Bitwise OR operation strictly increases in reverse order. e.g.\n``` \nInput: nums = [4,1,2]\nBitwise maximum OR: [7,3,2] \n```\nWe should iterate through the array `nums` in reverse, because if we also store the last index we see each bit, we can now find the right end of the subarray in O(1) time.\n\n# Approach\n\n    n == nums.length\n    1 <= n <= 10 000\n    0 <= nums[i] <= 1 000 000 000\n1. Initialise a `largest` bitset with 31 bits, to store nums[i]\n2. Initialise a `bits` vector to store the last index we see any bit\n3. Iterate through the `nums` array backwards, updating `bits` and `largest` for each element, then checking the minimal subarray size using `bits`\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(const vector<int>& nums) {\n        vector<int> ans;\n        ans.reserve(nums.size());\n        bitset<31> largest;\n        vector<int> bits(31, nums.size() - 1);\n\n        // O(n)\n        for (int i = nums.size() - 1; i >= 0; i--) {\n            // O(1) \n            int temp = nums[i], counter = 0;\n            while (temp != 0) {\n                if (temp & 1 == 1) {\n                    largest.set(counter);\n                    bits[counter] = i;\n                }\n                counter++;\n                temp >>= 1;\n            }\n            \n            // O(1)\n            int right = 0;\n            for (int j = 0; j < 31; j++) {\n                if (largest.test(j)) {\n                    right = max(right, bits[j]);\n                }\n            }\n\n            // O(1)\n            ans.push_back(max(right - i + 1, 1));\n        }\n\n        // O(n)\n        reverse(ans.begin(), ans.end());\n        return ans;\n    }\n};\n```
['C++']