Python | Greedy
Code\n\nfrom collections import Counter\nclass Solution:\n    def maximumOr(self, nums: List[int], k: int) -> int:\n        counter = [0]*32\n        for num in
# Code\n```\nfrom collections import Counter\nclass Solution:\n    def maximumOr(self, nums: List[int], k: int) -> int:\n        counter = [0]*32\n        for num in nums:\n            for i in range(32):\n                counter[i] += num & 1\n                num = num >> 1\n        res = 0\n        for j, num in enumerate(nums):\n            tmp = num\n            for i in range(32):\n                counter[i] -= tmp & 1\n                tmp = tmp >> 1\n            tmpres = 0\n            for i in range(32):\n                tmpres += (counter[i] > 0)*(1<<i)\n            tmpres = tmpres | (num << k)\n            res = max(res, tmpres)\n            tmp = num\n            for i in range(32):\n                counter[i] += tmp & 1\n                tmp = tmp >> 1\n        return res\n```
['Python3']