simple code

  • 0

    I am not sure if this code will use extra space?

    class Solution(object):
    def findDisappearedNumbers(self, nums):
    :type nums: List[int]
    :rtype: List[int]
    return [i for i in range(1,len(nums)+1) if i not in set(nums)]

  • 0

    It uses O(n) space since you create a set of integers.

  • 0

    And it's not O(n) time but only O(n2) time.

Log in to reply

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