Optimized----//////O(n)-Time and Space complexity\\\\\\
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def maximumOr(self, nums: List[int], k: int) -> int:\n        n = len(nums)\n        m = pow(2,k)\n        if n==1 : return nums[0]*m\n\n        #find prefix and suffix OR in single loop\n\n        pre = [nums[0]]*n\n        suf = [nums[-1]]*n\n        j = n-2\n        for i in range(1,n):\n            pre[i]=nums[i]|pre[i-1]\n            suf[j]=nums[j]|suf[j+1]\n            j-=1\n        \n        \'\'\'initialize ans with applying operation max \n            of first 1st or last element\'\'\'\n\n        ans = max((nums[0]*m) | suf[1] , (nums[-1]*m) | pre[-2])\n        for ind in range(1,n-1):\n            ans = max(ans,pre[ind-1]|(nums[ind]*m)|suf[ind+1])\n\n        return ans\n\n\n\n\n```
['Python3']