#K78487. Remove Duplicate Product IDs

    ID: 35097 Type: Default 1000ms 256MiB

Remove Duplicate Product IDs

Remove Duplicate Product IDs

You are given a list of product IDs. Your task is to remove any duplicates while maintaining the order of their first occurrence.

The problem can be formally described as follows:

Given a sequence \(a_1, a_2, \dots, a_n\) where each \(a_i\) is a product identifier (string), produce a sequence \(b_1, b_2, \dots, b_k\) such that:

  • \(b_1\) is \(a_1\).
  • For each \(i > 1\), \(a_i\) is added to the sequence if and only if it has not appeared among \(a_1, a_2, \dots, a_{i-1}\).

Output the resulting list with a single space separating each product ID.

inputFormat

The input is received from standard input (stdin) and is formatted as follows:

  1. An integer \(n\) (\(0 \le n \le 10^5\)), representing the number of product IDs.
  2. \(n\) lines follow, each line containing a non-empty string representing a product ID.

If \(n\) is 0, there will be no product IDs provided.

outputFormat

Output a single line to standard output (stdout) containing the unique product IDs in the order they first appeared, separated by a single space. If no product IDs are provided, output an empty line.

## sample
5
A123
B456
A123
C789
B456
A123 B456 C789

</p>