O(n) Time Simple Greedy Algorithm Beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \nWe will always use a single element to apply k operations on it  \n# Approach\n Describ
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe will always use a single element to apply $$k$$ operations on it  \n# Approach\n<!-- Describe your approach to solving the problem. -->\nApply $$k$$ steps on every $$a[i]$$ and return the maximum of all\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n# Code\n```\n//~~~~~~~~~~~~~MJ\xAE\u2122~~~~~~~~~~~~~\n#include <bits/stdc++.h>\n#pragma GCC optimize("Ofast")\n#pragma GCC optimize("unroll-loops")\n#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")\n#define Code ios_base::sync_with_stdio(0);\n#define by cin.tie(NULL);\n#define Hayan cout.tie(NULL);\n#define append push_back\n#define all(x) (x).begin(),(x).end()\n#define allr(x) (x).rbegin(),(x).rend()\n#define vi vector<ll>\n#define yes cout<<"YES";\n#define no cout<<"NO";\n#define vb vector<bool\n#define vv vector<vector<int>>\n#define ul unordered_map<int,vi>\n#define ub unordered_map<int,bool>\n#define ui unordered_map<int,int>\n#define sum(a) accumulate(all(a),0)\n#define add insert\n#define ll long long\n#define endl \'\\n\'\n#define pi pair<int,int>\n#define ff first\n#define ss second\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& a, ll k) \n    {\n        Code by Hayan\n        ll n=a.size();\n\n        //prefix arr and suffix arr\n        vi pre,suf;\n\n        ll c=0;\n        for (ll i=0;i<n;i++)\n        {\n            //prefix bitwise or calculating\n            pre.append(c);\n            c|=a[i];\n        }\n\n        c=0;\n        for (ll i=n-1;i>-1;i--)\n        {\n            //suffix bitwise or calculating\n            suf.append(c);\n            c|=a[i];\n        }\n\n        ll ans=0;\n        for (ll i=0;i<n;i++)\n        {\n            // if a[i] is used\n            ll used=1LL*(a[i])*(1<<(k));\n            ans=max(ans,0LL|pre[i]|suf[n-i-1]|used);\n        }\n    return ans;\n        \n\n    }\n};\n```
['C++']