Easy C++ solution using prefix and suffix
Intuition\nApply the operation k time on single element only.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nMaintain prefix and s
# Intuition\nApply the operation k time on single element only.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nMaintain prefix and suffix vector which keep the track of the OR of all the elements left to i and right to i respectively.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int i,n=nums.size();\n\n        vector<int> prefix(n,0),suffix(n,0);\n\n        for(i=1;i<n;i++){\n            prefix[i]=prefix[i-1] | nums[i-1];\n        }\n\n        for(i=n-2;i>=0;i--){\n            suffix[i]=suffix[i+1] | nums[i+1];\n        }\n\n        long long ans=0;\n\n        for(i=0;i<n;i++){\n            long long x=nums[i];\n            x<<=k;\n\n            ans=max(ans,prefix[i] | x| suffix[i]);\n        }\n\n        return ans;\n    }\n};\n```
['C++']