#C9169. Find the Missing Numbers
Find the Missing Numbers
Find the Missing Numbers
You are given an array of n integers. The task is to find all the missing numbers in the range \( [1, N] \) where \( N = \max(\max(\text{array}), n) \). In other words, you should determine which numbers within this range are not present in the array.
For example, if the input array is [7, 3, 1, 4, 8, 6, 2]
, the number \( N \) is \(8\) (since \(\max(8,7)=8\)). The numbers in the range \( [1, 8] \) are \(1, 2, 3, 4, 5, 6, 7, 8\), and the missing number is 5
.
Please note that the array can contain duplicate elements, and your output should list the missing numbers in ascending order. If there are no missing numbers, print an empty line.
inputFormat
The first line contains a single integer \( n \) representing the number of elements in the array.
The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Print the missing numbers from the range \( [1, N] \), in ascending order, separated by a single space. If there are no missing numbers, print an empty line.
## sample7
7 3 1 4 8 6 2
5
</p>