#C2623. Remove Duplicates from Datasets
Remove Duplicates from Datasets
Remove Duplicates from Datasets
You are given several datasets of integers. For each dataset, remove all duplicate values while preserving the order in which the values appear (i.e. only the first occurrence should be kept). Formally, for each dataset \(A=[a_1, a_2, \dots, a_n]\) you must produce a dataset \(B\) such that:
\(B= [a_{i_1}, a_{i_2}, \dots, a_{i_k}]\), where \(i_1 < i_2 < \dots < i_k\) and for any element \(a_{i}\) that appears in \(B\), it is the first occurrence in \(A\).
Input will be provided via standard input and output should be written to standard output following the format described below.
inputFormat
The input begins with an integer \(T\) representing the number of datasets. For each dataset, the first line contains an integer \(N\) representing the number of elements in the dataset. The following line contains \(N\) integers separated by spaces.
Example:
2 9 4 5 6 5 4 7 8 4 9 10 1 2 3 4 5 5 4 3 2 1
outputFormat
For each dataset, print a single line containing the integers after removal of duplicate values, separated by a single space. If a dataset is empty, output an empty line.
Example Output:
4 5 6 7 8 9 1 2 3 4 5## sample
1
9
4 5 6 5 4 7 8 4 9
4 5 6 7 8 9