Prefix OR
I first solved this problem by trying to find the best number to double for each iteration of k.\n\nWrong Answer.\n\nThen I realize that you just need to pick o
I first solved this problem by trying to find the best number to double for each iteration of `k`.\n\nWrong Answer.\n\nThen I realize that you just need to pick one number and double it `k` times. \n\n**C++**\n```cpp\nlong long maximumOr(vector<int>& nums, int k) {\n    vector<int> pref_or{0};\n    partial_sum(begin(nums), end(nums), back_inserter(pref_or), bit_or<>());\n    long long res = 0, suf_or = 0;\n    for (int i = nums.size() - 1; i >= 0; suf_or |= nums[i--])\n        res = max(res, pref_or[i] | ((long long)nums[i] << k) | suf_or);\n    return res;\n}\n```
['C']