my solution with space O(1)


  • 0
    M

    class Solution(object):

    def findDisappearedNumbers(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        l=len(nums)
        ans=[]; nums=list(set(nums))
        i,j=1,0
        while i<=l:
            if nums[j]==nums[-1]: j=-1
            if i== nums[j]:
                j+=1
            else: 
                ans+=i,
            i+=1
        return ans

Log in to reply
 

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