#C13690. Remove Duplicates from a List

    ID: 43256 Type: Default 1000ms 256MiB

Remove Duplicates from a List

Remove Duplicates from a List

You are given a list of n integers. Your task is to remove all duplicate elements while preserving the original order of their first occurrence. If the list is empty, output an empty line.

Task: Read the integer n which represents the number of elements, followed by n integers. Process the list to eliminate any duplicates and then print the unique elements in the order they first appeared, separated by spaces.

Note: The order of elements must be maintained as in the input.

inputFormat

The input is given via standard input (stdin) with the following format:

  • The first line contains an integer n representing the number of elements in the list.
  • The second line contains n space-separated integers.

outputFormat

Output a single line to standard output (stdout) that contains the unique integers (after removing duplicates) in their original order, separated by a single space. If the list is empty, output an empty line.

## sample
5
1 2 3 2 1
1 2 3