Easy prefix and suffix approach ✅ || Beats 88%
\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g. O(n) \n\n
\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    \n    long long maximumOr(vector<int>& nums, int k) {\n        int n = nums.size();\n        long long ans = 0;\n        vector<long long> prefix(n+1, 0);\n        vector<long long> suffix(n+1, 0);\n        long long temp = 1 << k;\n        \n        for(int i = 0; i < n; i++){\n            prefix[i+1] = nums[i] | prefix[i];\n        }\n        for(int i = n-1; i >= 0; i--){\n            suffix[i] = nums[i] | suffix[i+1];\n        }\n        \n        for(int i = 0; i < n; i++){\n            ans = max((prefix[i] | suffix[i+1] | temp*nums[i]), ans);\n        }\n        return ans;\n\n    }\n};\n```
['Bit Manipulation', 'Suffix Array', 'Prefix Sum', 'C++']