2568. Minimum Impossible OR
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 58% Topics: Array, Bit Manipulation, Brainteaser
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(logr)
# Space: O(1)
# hash table, bit manipulations
class Solution(object):
def minImpossibleOR(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
lookup = set(nums)
return next(1<<i for i in xrange(31) if 1<<i not in lookup)
Solution from kamyu104/LeetCode-Solutions · MIT