[Java/C++/Python] Easy One Pass
Intuition\nThe best plan is to double the same number k times\nthis will shift the leftmost bit to left k bits.\n\n\n# Explanation\nright[i] = A[i + 1] * A[i + 
# **Intuition**\nThe best plan is to double the same number `k` times\nthis will shift the leftmost bit to left `k` bits.\n<br>\n\n# **Explanation**\n`right[i] = A[i + 1] * A[i + 2] * ... * A[n - 1]`\n`left[i] = A[0] * A[1] * ... * A[i - 1]`\n\nSo the result for doubling `A[i]` is\n`left[i] | A[i] << k | right[i]`.\n\nOne pass `A` and return the result.\n<br>\n\n# **Complexity**\nTime `O(n)`\nSpace `O(n)`\n<br>\n\n**Java**\n```java\n    public long maximumOr(int[] A, int k) {\n        int n = A.length, right[] = new int[n], left = 0;\n        long res = 0;\n        for (int i = n - 2; i >= 0; --i) {\n            right[i] = right[i + 1] | A[i + 1];\n        }\n        for (int i = 0; i < n; i++) {\n            res = Math.max(res, left | (long)A[i] << k | right[i]);\n            left |= A[i];\n        }\n        return res;\n    }\n```\n\n**C++**\n```cpp\n    long long maximumOr(vector<int> &A, int k) {\n        int n = A.size(), left = 0;\n        vector<int> right(n);\n        long res = 0;\n        for (int i = n - 2; i >= 0; --i) {\n            right[i] = right[i + 1] | A[i + 1];\n        }\n        for (int i = 0; i < n; i++) {\n            res = max(res, left | (long)A[i] << k | right[i]);\n            left |= A[i];\n        }\n        return res;\n    }\n```\n\n**Python**\n```py\n    def maximumOr(self, A: List[int], k: int) -> int:\n        res, left, n = 0, 0, len(A)\n        right = [0] * n\n        for i in range(n - 2, -1, -1):\n            right[i] = right[i + 1] | A[i + 1]\n        for i in range(n):\n            res = max(res, left | A[i] << k | right[i])\n            left |= A[i]\n        return res\n```\n
['C', 'Python', 'Java']