Prefix - Suffix OR || Short & Simple Code
Complexity\n- Time complexity: O(n) \n\n- Space complexity: O(n) \n\n# Code\n\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n 
# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity: $$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        long long ans = 0, n = nums.size();\n        vector<int> prefix_or(nums.size(),0), suffix_or(nums.size(),0);\n\n        //calculate prefix and suffix or\n        for(int i = 1; i < nums.size(); i++){\n          prefix_or[i] = prefix_or[i-1] | nums[i-1];\n          suffix_or[n-i-1] = suffix_or[n-i] | nums[n-i];\n        }\n        //multiply each element by 2^k and take max of all\n        for(int i=0; i<nums.size(); i++) {\n            ans = max(ans,prefix_or[i] | (1LL*nums[i]<<k) | suffix_or[i]);\n        }\n     return ans;\n    }\n};\n```
['Array', 'Greedy', 'Bit Manipulation', 'Prefix Sum', 'C++']