DETAILED EXPLANATION for MAXIMUM OR
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst thought was to find the number with the leftmost set bit. But that would add to t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst thought was to find the number with the leftmost set bit. But that would add to the complexity.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSo basically, what we want here, is to multiply every number by 2, k times, and take its OR with the rest of the array.\nWe have to do this k times.\nThis means the number having the leftmost MSB 1, will give us the max ans.\n\nSo here, for each array element, we can have pre and post arrays.\nWhat these will store is -> pre will store the OR of the elements which are before that element(the current number is not included)\n\npost will store the OR of the elements after it(not the current element or the elements before it),\n\nint this way for each element we will be able to check if it gives the maximum ans, as for each nums[i], we will have current OR as -> pre[i] | nums[i] | post[i].\n\nKeep maximising this until the end of the loop.\n\nyou will get your answer.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        \n        int n = nums.size();\n        long long maxi = 0;\n\n        vector<int> pre(n,0), post(n,0);\n\n        for(int i=1; i<n; i++){\n            pre[i] = (pre[i-1] | nums[i-1]);\n        }\n\n        for(int i=n-2; i>=0; i--){\n            post[i] = (post[i+1] | nums[i+1]);\n        }\n\n        for(int i=0; i<n; i++){\n            long long num = nums[i];\n            num *= pow(2,k);\n            maxi = max(maxi, pre[i]|num|post[i]);\n        }\n\n        return maxi;\n    }\n};\n```
['C++']