#C14269. Remove Duplicates While Maintaining Order

    ID: 43899 Type: Default 1000ms 256MiB

Remove Duplicates While Maintaining Order

Remove Duplicates While Maintaining Order

You are given a list of strings. Your task is to remove any duplicate strings while preserving the order of their first occurrences. For example, given the list:

["apple", "banana", "apple", "cherry", "banana"]

the resulting list should be:

["apple", "banana", "cherry"]

The problem can be formulated as follows:

Given a list \( S = [s_1, s_2, \dots, s_n] \), remove all duplicate occurrences such that only the first appearance of each string remains. The order of strings must be preserved.

inputFormat

The input consists of a single line containing a space-separated list of strings. If the input is empty, treat it as an empty list.

outputFormat

Output the list of strings after duplicates have been removed, preserving the order of their first occurrences. The output should be printed as space‐separated values on a single line.

## sample
apple banana apple cherry banana
apple banana cherry

</p>