Simple Java solution.
\n\n# Code\n\nclass Solution {\n    public long maximumOr(int[] nums, int k) {\n        int n = nums.length;\n        long[] prefix = new long[n];\n        long
\n\n# Code\n```\nclass Solution {\n    public long maximumOr(int[] nums, int k) {\n        int n = nums.length;\n        long[] prefix = new long[n];\n        long[] suffix = new long[n];\n        prefix[0] = 0;\n        suffix[n-1] = 0;\n        for(int i= 1;i<n;i++)\n        {\n            prefix[i] = prefix[i-1]|nums[i-1];\n        }\n        for(int i=n-2;i>=0;i--)\n        {\n            suffix[i] = suffix[i+1]|nums[i+1];\n        }\n        long max =0;\n        for(int i=0;i<n;i++)\n        {\n            long val = prefix[i]|suffix[i];\n            long v = nums[i]*(long)Math.pow(2,k);\n            max = Math.max(max,val|v);\n        }\n        return max;\n    }\n}\n```
['Java']