❄ Easy Java Solution❄Beats 100% of Java Users .
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public long maximumOr(int[] a, int k) {\n        int n = a.length;\n        if( n == 1 ){\n            long e = a[0] ; \n            return e << k ; \n        }\n        int[] r = new int[n] ;  \n        r[n-1] = a[n-1] ; \n        for( int i=n-2 ; i>0 ; --i ){\n            r[i] |= r[i+1] ; \n            r[i] |= a[i] ; \n        }\n        long e = r[1] ; \n        long rs =( e | ( (long) a[0] << k ) ) ; \n        long pref = a[0] ; \n        for( int i=1 ; i<n-1 ; ++i ){\n            rs = Math.max( rs , ( pref | r[i+1] | ( (long) a[i] << k))) ; \n            pref |= a[i] ; \n        }\n        rs = Math.max( rs , pref|( (long) a[n-1] << k  ) ) ; \n        return rs ; \n    }\n}\n\n```
['Array', 'Greedy', 'Bit Manipulation', 'Prefix Sum', 'Java']