CPP Solution using prefix OR and suffix OR
\n# Code\n\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& l, int k) {\n        vector<long long> nums(l.size());\n        int n = nums.size();
\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& l, int k) {\n        vector<long long> nums(l.size());\n        int n = nums.size();\n        for (int i = 0; i < n; i++) nums[i] = l[i];\n        vector<int> pr(n), sf(n);\n        pr[0] = nums[0];\n        sf[n-1]=nums[n-1];\n        for (int i = 1; i < n; i++) \n            pr[i] = pr[i - 1] | nums[i];\n        for (int i = n - 2; i >= 0; i--) \n            sf[i] = sf[i + 1] | nums[i];\n        nums.insert(nums.begin(), 0);\n        pr.insert(pr.begin(), 0);\n        sf.insert(sf.begin(), 0);\n        pr.push_back(0);\n        sf.push_back(0);\n        for (int i = 1; i < n + 1; i++) {\n            nums[i] = nums[i] * pow(2, k);\n        }\n        long long ans = INT_MIN;\n        for (int i = 1; i < n + 1; i++) {\n            long long x = nums[i] | pr[i - 1] | sf[i + 1];\n            ans = max(ans, x);\n        }\n        return ans;\n    }\n};\n```
['C++']