#C4747. Find Missing Numbers

    ID: 48319 Type: Default 1000ms 256MiB

Find Missing Numbers

Find Missing Numbers

Given a positive integer ( n ) and an array of integers ( arr ) where each element of ( arr ) is between ( 1 ) and ( n ) (inclusive), your task is to find and output all the numbers in the range ( [1, n] ) that do not appear in ( arr ). The output should be sorted in ascending order.

For instance, if ( n = 8 ) and ( arr = [4, 3, 2, 7, 8, 2, 3, 1] ), the numbers 5 and 6 are missing from the array, so your program should output: 5 6.

inputFormat

The input is read from standard input (stdin) and consists of three lines:
1. The first line contains a single integer ( n ), which represents the upper bound of the range ( [1, n] ).
2. The second line contains an integer ( m ) denoting the number of elements in the array ( arr ).
3. The third line contains ( m ) space-separated integers representing the array ( arr ). Note that ( m ) can be 0, in which case the third line will be empty.

outputFormat

Output the missing numbers in ascending order to standard output (stdout). The missing numbers should be printed on a single line separated by a single space. If there are no missing numbers, output an empty line.## sample

8
8
4 3 2 7 8 2 3 1
5 6

</p>