Easy Solution with SC & TC & Intution
\n# Intution\n  1. We do k operations on ONE picked element => This is because if a number is picked and a operation is done once it is giving max result , then
\n# Intution\n  1. We do k operations on ONE picked element => This is because if a number is picked and a operation is done once it is giving max result , then this means doing it k times maximisesour ans (we are left shifing each time)\n2. Why not maximum element picked give correct ans?\n        \n    ->eg: \n        12: 1 1 0 0\n         9: 1 0 0 1\n        \n        24: 1 1 0 0 0      12:   1 1 0 0\n        9:    1 0 0 1      18: 1 0 0 1 0 \n        25                 30\n        So, In case numbers are in NOT very far from each , we cant pick the the greatest . We have to TRY Each element\n\n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n$$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumOr(vector<int>& nums, int k) {\n        int n = nums.size();\n        long long ans = 0,p = 1;\n        vector<long long> prefix_or(n,0),suffix_or(n,0);\n\n        p = p<<k;\n\n        prefix_or[0] = nums[0];\n        for(int i=1;i<n;i++){\n            prefix_or[i] = prefix_or[i-1]|nums[i];\n        }\n        suffix_or[n-1] = nums[n-1];\n        for(int i=n-2;i>=0;i--){\n            suffix_or[i] = suffix_or[i+1]|nums[i];\n        }\n\n        for(int i=0;i<n;i++){\n            long long small_ans =  (i>=1?prefix_or[i-1]:0)|(i<=n-2?suffix_or[i+1]:0)|(nums[i]*p);\n            ans = max(ans,small_ans);\n        }\n\n        return ans;\n\n    }\n\n};\n```
['C++']