C++ || bit wise index, transform from back || fast (100%, 116ms)
Solution 1: index per bit, transform from the back\n\nFor each bit we keep track of the "nearst" index at which it is set and if we scan from the back we can re
### Solution 1: index per bit, transform from the back\n\nFor each bit we keep track of the "nearst" index at which it is set and if we scan from the back we can rewrite ```nums``` as we go.\n\n```\n    static vector<int> smallestSubarrays(vector<int>& nums) {\n        array<int, 30> idx = {};\n        for (int i = size(nums) - 1; i >= 0; --i) {\n            const int num = nums[i];\n            for (int j = 0; j < size(idx); ++j) {\n                if (num & (1 << j)) {\n                    idx[j] = i;\n                }\n            }\n            const int mx = *max_element(begin(idx), end(idx));\n            nums[i] = max(mx, i) - i + 1;\n        }\n        return nums;\n    }\n```\n\n_As always: Feedback, comments, and questions are welcome. Please upvote if you like the post._
[]