#C12314. Remove Duplicates in a List

    ID: 41728 Type: Default 1000ms 256MiB

Remove Duplicates in a List

Remove Duplicates in a List

Given a list of integers, possibly containing duplicates, remove all duplicate values while preserving the order of their first appearance.

Consider a list (L = [a_1, a_2, \dots, a_n]). You are required to output a new list (R) such that each element in (R) appears only once and in the same order as they first appear in (L).

For example, if (L = [1, 2, 2, 3, 4, 4, 5]), then (R = [1, 2, 3, 4, 5]).

inputFormat

The input is given via standard input (stdin). The first line contains an integer (N), representing the number of elements in the list. The second line contains (N) space-separated integers.

outputFormat

Print the unique integers in the order they first appeared in the list. The output should be printed on standard output (stdout) with each number separated by a single space.## sample

7
1 2 2 3 4 4 5
1 2 3 4 5