#K80532. Removing Duplicates from a List

    ID: 35551 Type: Default 1000ms 256MiB

Removing Duplicates from a List

Removing Duplicates from a List

In this problem, you are given a list of integers. Your task is to remove the duplicate values while preserving the order of their first occurrence. Formally, for an input list (L = [a_1, a_2, \dots, a_n]), you need to produce another list (L') such that each element in (L') appears exactly once and in the same order as its first appearance in (L).

You must read the input from standard input (stdin) and output your result to standard output (stdout). The input is given as a single line of space-separated integers. If the input is empty, output an empty line.

inputFormat

A single line containing a sequence of space-separated integers. It is possible that the input line is empty, in which case your program should output an empty line.

outputFormat

Output a single line containing the space-separated integers after removing duplicates while preserving the order of their first occurrence.## sample

4 5 6 5 4 7 8 8 4 5 9
4 5 6 7 8 9