Max OR || C++ || Explanation for optimal result
IntuitionLeft shift the index since it is multiplied by 2.ApproachThe most optimal approach is to precompute the prefix and suffix or of the vector for each ind
# Intuition
Left shift the index since it is multiplied by 2.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
The most optimal approach is to precompute the prefix and suffix or of the vector for each index. Performing k operations on the same value will give maximum result. So the index whose set bit is farthest when left shifted more k times will provide the best output.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    long long maximumOr(vector<int>& nums, int k) {
        long long max_or = 0;
        int n = nums.size();
        vector<int>prefix(n+1), suffix(n+1);

        for(int i=1;i<n;i++){
            prefix[i] = prefix[i - 1] | nums[i - 1];
            suffix[n-1-i] = suffix[n - i] | nums[n - i];
        }
        for(int i=0;i<n;i++){
            max_or = max(max_or, prefix[i] | ((long long)nums[i] << k) | suffix[i]);
        }
        return max_or;
    }
   
};
```
['Bit Manipulation', 'Prefix Sum', 'C++']