Python O(n) time O(1) space bit vector solution

  • 0
    class Solution(object):
        def findDuplicate(self, nums):
            vector = 0
            for x in nums:
                offset = 1 << x
                if vector & offset:
                    return x
                vector |= offset

    Correct me if this is not considered o(1) space

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.