#C13451. Remove Duplicates from List
Remove Duplicates from List
Remove Duplicates from List
Given a list of integers, remove all duplicate elements while preserving the order of their first occurrence. That is, only the first appearance of each integer is kept, and any subsequent duplicates are discarded.
Note: The order of the elements must remain the same as in the input. For example, if the input list is [4, 5, 1, 2, 4, 1, 3]
, the output should be [4, 5, 1, 2, 3]
.
inputFormat
The input is given through standard input (stdin) and consists of two lines:
- 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 resulting list after removing duplicates, with numbers printed on one line and separated by a single space. The output is sent to standard output (stdout).
## sample5
1 2 3 4 5
1 2 3 4 5