#C8890. Remove Duplicates and Preserve Order
Remove Duplicates and Preserve Order
Remove Duplicates and Preserve Order
You are given a list of integers. Your task is to remove all duplicate elements while preserving the original order of the remaining elements.
For example, if the input list is [1, 2, 2, 3, 4, 4, 5], the correct output is [1, 2, 3, 4, 5].
Note: If the list is empty, the output should be empty as well.
The mathematical formulation: Given a list , find the list such that each element appears only once and the order is preserved.
inputFormat
The first line of input contains an integer , the number of elements in the list. The second line contains space-separated integers.
outputFormat
Output a single line containing the list after removing duplicates, with the remaining elements separated by a single space. If the list is empty, output nothing.## sample
7
1 2 2 3 4 4 5
1 2 3 4 5