Python 3   ||   7 lines,  w/explanation   ||   T/S: 99% / 99%
Here\'s the plan:\n1. We determine the maximum number of bits for elements innums.\n2. We compile those elements innumsthat have the maximum number of bits (n) 
Here\'s the plan:\n1. We determine the maximum number of bits for elements in`nums`.\n2. We compile those elements in`nums`that have the maximum number of bits (`n`) in the array`cands`. (The answer will be determined by left-shifting one of these elements.)\n3. We iterate through`nums`, keeping track of the bits seen (`bits`) and bits seen more than once (`extraBits`). \n\n4. We assess which element`c`of`cands`provides the *maximum or* after left-shifting`k`bits by: (a) xoring the bits of`c`from`bits`; (b) unioning the bits of`c << k`to`bits`to reflect the left-shifting of `c`; and (c) unioning the bits of`extraBits`to`bits`to replace bits incorrectly removed by the xoring. \n\n.\n```\nclass Solution:\n    def maximumOr(self, nums: List[int], k: int) -> int:\n\n        bits, extraBits, mx, cands = 0, 0, 0, []\n        n = 1<<int(log2(max(nums)))                 # <-- 1)\n\n        for num in nums:\n            if num >= n: cands.append(num)          # <-- 2)\n\n            extraBits|= num&bits                    # <-- 3)\n            bits|= num                              #\n            \n        return max(bits^c |                         # <-- 4a)\n                   c << k |                         # <-- 4b)\n                   extraBits for c in cands)        # <-- 4c)\n```\n[https://leetcode.com/problems/maximum-or/submissions/1294048595/](https://leetcode.com/problems/maximum-or/submissions/1294048595/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums).\n
['Python', 'Python3']