Explained - Very simple & easy to understand solution
Up vote if you like the solution \n# Approach \n1. Evaluate 2^k\n2. Then calculate prefix & suffix bit wise value and store it\n3. check each number by multiply
<b>Up vote if you like the solution </b>\n# Approach \n1. Evaluate 2^k\n2. Then calculate prefix & suffix bit wise value and store it\n3. check each number by multiplying 2^k, if it has max ans or not.\n\nQ. Why this works :\nAns :  When we multiply a number by 2 then this equal to shifting the values to the left by 1 places. \nSo to have a largest value we should shift a single number to the k number of times which end up with max value possible.\nnow we don\'t know exactly which value to shift k times, so we check the same for all possible numbers and keep tracking the max value.\n\n# Code\n```\n\n    long long maximumOr(vector<int>& nums, int k) {\n        long long ans = 0, mul = 1;\n        vector<long long> pre(nums.size(), 0), suf(nums.size(), 0);\n        pre[0] = nums[0]; suf[nums.size()-1] = nums.back();\n        for( int i = 1; i < nums.size(); ++i) {\n            pre[i] = pre[i-1] | nums[i];\n            suf[nums.size() - i - 1] = suf[nums.size()-i] | nums[nums.size() - i - 1];\n        }\n        for(int i = 0; i < k; ++i){ mul *= 2; }\n        for(int i = 0; i < nums.size(); ++i){\n            long long x = nums[i]*mul;\n            if(i-1 >= 0) x = x | pre[i-1];\n            if(i+1 < nums.size()) x = x | suf[i+1];\n            ans = max(ans, x);\n        }\n        return ans;\n    }\n\n```\n\n<b> Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted
['C++']