Find Disappeared Numbers

Given an array of integers from 1 to n with some values possibly duplicated, return all numbers in the range that do not appear. Index placement directly reveals which positions are never filled.

Input Format

nums = array of integers from 1 to n

Output Format

all missing numbers in ascending order

Constraints

  • 1 <= nums.length <= 10^5; 1 <= nums[i] <= nums.length

Examples

Example 1:

Input:

nums = [4,3,2,7,8,2,3,1]

Output:

[5,6]

Explanation:

5 and 6 never appear in the array.

Example 2:

Input:

nums = [1,1]

Output:

[2]

Explanation:

Only 1 appears, so 2 is missing.

Loading...
Find Disappeared Numbers