Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find All Numbers Disappeared in an Array

XPChallenge Points: 10
levelLevel: Easy

You are given an integer array nums of length n, where each element nums[i] lies in the range [1, n].
Your task is to find all numbers between 1 and n (inclusive) that do not appear in the array.
The output should be returned as a list of missing numbers in ascending order.

Example 1:

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

Output: [8, 10]

Explanation:

The numbers from 1 to 10 are expected, but 8 and 10 are missing from the array.

Example 2:

Input: nums = [2, 2, 3, 1, 5, 5]

Output: [4, 6]

Explanation:

Numbers 4 and 6 are not present in the range [1, 6].

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result