Closest bit O(n) C++
Remember the last position you saw a \'1\' for each bit in 32 bits int.\nFor each element find the idx you found the \'1\' that it furthest appart. That is the 
Remember the last position you saw a \'1\' for each bit in 32 bits int.\nFor each element find the idx you found the \'1\' that it furthest appart. That is the minimum length of the array.\n\n```\nvector<int> smallestSubarrays(vector<int>& nums) {\n\tint n = nums.size();\n\n\tvector<int> ans(n);\n\n\tunordered_map<int,int> idx;\n\tfor (int i = 0; i < 32; ++i) {\n\t\tidx[1 << i] = n;\n\t}\n\n\tfor (int i = n - 1, m = 0, j = 0; i >= 0; --i) {\n\t\tj = i;\n\t\tm |= nums[i];\n\t\tfor (int num = m; num; ) {\n\t\t\tint lsb = (num & -num);\n\t\t\tif (nums[i] & lsb) idx[lsb] = i; // closest satisfied                \n\t\t\tj = max(j, idx[lsb]); // furthest j\n\t\t\tnum ^= lsb; // flip\n\t\t}\n\t\tans[i] = j - i + 1;\n\t}\n\n\treturn ans;\n}\n```
['C']