SUFFIX || PREFIX || C++ || EASY TO UNDERSTNAD
Code\n\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int n = nums.size(),i;\n        if(n==1)return ((nums[0]*1LL)<<k
# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int n = nums.size(),i;\n        if(n==1)return ((nums[0]*1LL)<<k);\n        vector<int> p(n,0),s(n,0);\n        p[0] = nums[0];\n        for(i = 1; i < n; i++){\n            p[i] = (p[i-1]|nums[i]);\n        }\n        s[n-1] = nums[n-1];\n        for(i = n-2; i >=0; i--){\n            s[i] = (s[i+1]|nums[i]);\n        }\n        long long int ans = 0;\n        for(int i = 0; i < n; i++){\n            if(i==0){\n                ans = max(ans,((nums[i]*1LL)<<k)|s[i+1]);\n            }else if(i==n-1){\n                ans = max(ans,((nums[i]*1LL)<<k)|p[i-1]);\n            }else{\n                ans = max(ans,((nums[i]*1LL)<<k)|s[i+1]|p[i-1]);\n            }\n        }\n        return ans;\n    }\n};\n```
['Array', 'Dynamic Programming', 'Suffix Array', 'Prefix Sum', 'C++']