#3731

Find Missing Elements

easy · 82.9% accepted · 72 likes · top 94%

array · hash table · sorting

Description

You are given an integer array nums consisting of unique integers.

Originally, nums contained every integer within a certain range. However, some integers might have gone missing from the array.

The smallest and largest integers of the original range are still present in nums.

Return a sorted list of all the missing integers in this range. If no integers are missing, return an empty list.

Solution