#K75652. Remove Duplicates from a List
Remove Duplicates from a List
Remove Duplicates from a List
Given a list of integers, remove the duplicates while preserving the order of their first occurrences. In this problem, you are required to read a list of integers from standard input and output the modified list to standard output.
Task: Remove duplicate values and output the remaining integers in the order they first appeared.
The duplicate removal process can be mathematically described using the concept of a set. Given a sequence \(a_1, a_2, \dots, a_n\), form a new sequence \(b_1, b_2, \dots, b_k\) where each \(b_i\) is the first occurrence of each distinct integer in the original sequence.
inputFormat
The input begins with a single integer n, denoting the number of integers in the list. The following line contains n space-separated integers.
Example:
7 1 2 2 3 4 4 5
outputFormat
Output the list of integers after removing the duplicates, separated by a single space. If the list is empty (i.e. n = 0), output nothing.
Example Output:
1 2 3 4 5## sample
7
1 2 2 3 4 4 5
1 2 3 4 5