[C++] Brute Force solution using map
Approach: \n For every index i, starting from the end, we are using all the Bitwise OR results from index i + 1 along with the size of the subarray. \n If two s
Approach: \n* For every index i, starting from the end, we are using all the Bitwise OR results from index i + 1 along with the size of the subarray. \n* If two subarrays have same Bitwise OR result then we keep only the shorter subarray. For this we are using a map. \n* For index i, we find the maximum Bitwise OR result having the smallest size.\n\n\nCode:\n```\nclass Solution {\npublic:\n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        vector<unordered_map<int, int>> ops(n);\n        ops[n - 1][nums.back()] = 1;\n        \n        vector<int> res(n, 1); \n        \n        for(int i = n - 2; i >= 0; i--){\n            int mx = nums[i], mxs = 1;\n            for(auto [v, s]: ops[i + 1]){\n                int x = nums[i] | v;\n                if(ops[i].count(x))\n                    ops[i][x] = min(ops[i][x], s + 1);\n                else ops[i][x] = s + 1;\n                if(x >= mx){\n                    if(mx == x){\n                        mxs = min(mxs, s + 1);\n                    }\n                    else {\n                        mx = x;\n                        mxs = s + 1;\n                    }                    \n                }\n            }  \n            ops[i][nums[i]] = 1;\n            res[i] = mxs;\n        }\n        return res;\n    }\n};\n```\n
['C']