#448

Find All Numbers Disappeared in an Array

pupil · 340 · lc easy +22 · verified · 63.8% accepted · 10,319 likes · top 66%

play →

Description

Given an array nums of n integers where every value lies in the range [1, n], some values may appear twice while others are missing. Return a list of every integer in [1, n] that does not appear in nums.

Example 1:

Input: nums = [4,3,2,7,8,2,3,1]
Output: [5,6]

Example 2:

Input: nums = [1,1]
Output: [2]

Code

1
2
3