EASY C++ USING PREFIX AND SUFFIX SUM
Intuition\nWe have to check on each element weather we can give multiply it for k times. Multiplying single element k time will give more larger result.\n\n# Ap
# Intuition\nWe have to check on each element weather we can give multiply it for k times. Multiplying single element k time will give more larger result.\n\n# Approach\nwe will store prefix and suffix or of each index in order to minimise time complexity.\n\nafter that we can iterate on each index multifly it with 2 for k times and take new or (pre[i] | val | suf[i+1]) it will give the or of array. we will store maximum in ret variable.\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n# Code\n```\nclass Solution {\npublic:\n    \n    long long maximumOr(vector<int>& nums, int k) {\n        \n        int n=nums.size();\n        int x=2;\n        vector<long long>pre(n+1,0),suff(n+1,0);\n        long long res, po = 1;\n \n\n        for (int i = 0; i < k; i++){\n            po *= x;\n        }\n        \n \n        for (int i = 0; i < n; i++){\n            pre[i + 1] = pre[i] | nums[i];\n        }\n        \n        suff[n] = 0;\n        for (int i = n - 1; i >= 0; i--){\n            suff[i] = suff[i + 1] | nums[i];\n        }\n        \n        res = 0;\n        for (int i = 0; i < n; i++){\n            res = max(res, pre[i] | (nums[i] * po) | suff[i + 1]);\n        }\n        \n \n        return res;\n    }\n};\n```\n\nPLEASEEE UPVOTEE IF IT HELPSS
['C++']