C++ || Prefix and suffix or
\n\n# Code\n\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int n=nums.size();\n        if(n==1)return nums[0]<<k;\n  
\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int n=nums.size();\n        if(n==1)return nums[0]<<k;\n        vector<long long>pre(n);pre[0]=nums[0];\n        for(int i=1;i<n;i++){\n            pre[i]=(long long)(nums[i] | pre[i-1]);\n        }\n        vector<long long>suf(n);suf[n-1]=nums[n-1];\n        for(int i=n-2;i>=0;i--){\n            suf[i]=(long long)(nums[i] | suf[i+1]);\n        }\n        long long ans=0;\n        for(int i=0;i<n;i++){\n            long long temp=nums[i];\n            temp=temp<<k;\n            if(i==0){\n                ans=max(ans,(long long)temp|suf[1]);\n            }\n            else if(i==n-1){\n                ans=max(ans,(long long)pre[n-2]|temp);\n            }\n            else{\n                ans=max(ans,(long long)(pre[i-1] | temp) | suf[i+1]);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']