Python Solution


  • 0
    S
    class Solution(object):
        def findDisappearedNumbers(self, nums):
            for k in range(3):
                for i, num in enumerate(nums):
                    if i + 1 != num:
                        nums[num - 1], nums[i] = nums[i], nums[num - 1]
    
            return [i + 1 for i, num in enumerate(nums) if i + 1 != num]

  • 0

    Doesn't work, for example claims that [2, 3, 4, 5, 6, 7, 8, 1] is missing [1, 5].


Log in to reply
 

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