#C10822. Remove Duplicates from List
Remove Duplicates from List
Remove Duplicates from List
You are given a list of integers. Your task is to remove all integers that appear more than once in the list, preserving the order of the remaining elements. In other words, only integers that occur exactly once in the input should be printed.
Example:
Input: 7 4 5 6 5 4 3 8 Output: 6 3 8
Note: The input is read from stdin
and the output is sent to stdout
. Use the following format for input and output.
Mathematically, if we denote the input array as \( A = [a_1, a_2, \dots, a_n] \), you need to compute the array \( B \) defined by
[ B = [a_i \in A \mid #{j: a_j = a_i} = 1] ]
and then print the elements of \( B \) separated by spaces.
inputFormat
The first line contains an integer \( n \) representing the number of elements in the list. The second line contains \( n \) integers separated by spaces.
outputFormat
Print the integers that appear exactly once in the list in their original order, separated by a space. If no such number exists, print nothing.
## sample4
1 2 3 4
1 2 3 4