What is wrong with my Python soluyion?


  • 0
    G

    class Solution(object):
    def findDisappearedNumbers(self, nums):
    """
    :type nums: List[int]
    :rtype: List[int]
    """
    res = []
    for i in xrange(len(nums)):
    while nums[nums[i] - 1] != nums[i]:
    nums[i],nums[nums[i] - 1] = nums[nums[i] - 1],nums[i]
    for i in xrange(len(nums)):
    if nums[i] != i + 1:
    res += [i + 1]
    return res


Log in to reply
 

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