#C12969. Remove Duplicates in List Preserving Order
Remove Duplicates in List Preserving Order
Remove Duplicates in List Preserving Order
Given a list of integers, your task is to remove the duplicate elements while preserving the order of their first occurrences. In other words, you need to output a new list that contains each number only once and in the same order as they first appeared in the input.
Note: Your solution must read data from stdin
and output the result to stdout
. If the input is empty, the output should also be empty.
inputFormat
The input consists of a single line containing space-separated integers. An empty input represents an empty list.
outputFormat
Print the distinct integers in their original order, separated by a single space. If there are no integers to print, output nothing.
## sample1 2 2 3 4 4 5
1 2 3 4 5